关于PHP文件及编码的有关问题
关于PHP文件及编码的问题
1:PHP代码文件本身的编码格式,是GB或者UTF8会影响什么?
2:PHP代码文件中是混杂的,有GB又有UTF8会导致什么样的不好结果么?
3:PHP语言中的字符串编码格式是什么?(比如C语言就是ASCII,但C#就是UNICODE,不知道PHP是什么)
4:PHP代码文件的编码格式跟MYSQL的数据库字符编码格式不同会导致什么不好的结果么?
5:MYSQL本身的编码格式会影响输出到页面上的文字的效果么?
问题好像有点多了,请大家指教,非常感谢.一定及时结帖给分.
------解决方案--------------------
1:PHP代码文件本身的编码格式,是GB或者UTF8会影响什么?
只要与 html 语言声明不冲突,就没有关系
2:PHP代码文件中是混杂的,有GB又有UTF8会导致什么样的不好结果么?
多半会差生“乱码”,而使你无所适从
3:PHP语言中的字符串编码格式是什么?(比如C语言就是ASCII,但C#就是UNICODE,不知道PHP是什么)
由你决定
4:PHP代码文件的编码格式跟MYSQL的数据库字符编码格式不同会导致什么不好的结果么?
只要通知 mysql 需要什么编码的内容,没有不好的结果
5:MYSQL本身的编码格式会影响输出到页面上的文字的效果么?
不会
------解决方案--------------------
1.一个人的血型是 O 或者A 会有什么影响?
2.一个人的血型又是O 又是A 某个时候是正常的 比如可能产生了稀有血液,大多数时候是直接死亡。
3.php你就是造物主 你想怎么造就怎么造.
4.不同会让你戴上1000度的眼镜也无法看明白那串乱码到底是什么... 当然改造一下眼镜问题也就解决了。
5.数据库就是你的弹仓,如果你不一哆嗦...那么他不会发射出来,他会老老实实的呆着,直到....你觉得足够兴奋,你要输出了.这个时候你才要考虑编码格式的事情.正确的解决方法就是 在建这个弹仓的时候 先考虑好所有编码的统一,就万事具备了。
------解决方案--------------------
程序文件用什么编码无所谓,只要兼容ASCII就行。关键是数据库存储用UTF-8就行
------解决方案--------------------
首先文件本身的编码格式要指定,并且项目中要统一。其次就是参数编码也要指定统一,否则中文会乱码。与mysql的编码不一致,要么设置mysql数据库的编码集要么用php转码函数转码,否则中文乱码
------解决方案--------------------
大神来了。(- -#)
源代码中的字面常量字符串的编码直接受源代码文件编码控制,举例:
$str = "你好吗";
1,如果是GBK编码保存的这三个汉字,那么硬盘上实际占用了6个字节。
2,如果是UTF8编码保存的这三个汉字,那么硬盘上实际占用了超过6个字节。
假如文件是UTF8保存的,那么你希望转化这个字符串为GBK的,并发给浏览器。
那么mb_convert_encoding($str, "utf8", "gbk")就会得到一个gbk编码的“你好吗”,而你这个函数的调用的效果就是告诉PHP解释器:这个字符串里的字节是UTF8编码的,你得按照UTF8编码解释这一段字节,并将这三个字符转化成GBK编码的6个字节。
之后echo输出到浏览器,并content type告诉浏览器这一段字节是gbk的,请按照gbk编码去解释这6个字节。
------解决方案--------------------
看了你这边说的有点晕....
CI的代码...如果没有记错,应该都是英文等...
新浪的开放平台不知道,但是一般情况下,代码也应该都是英文及符号等....
对于127以下的ascii字符,包括英文及符号,数字, 他们的ascii码和utf8码是完全一样的....
所以可能不存在你说的需要统一的问题
------解决方案--------------------
怎么处理?改成统一的编码
当然你也可以给 php 部分请个翻译。php 提供了 mb_string 和 iconv 两个函数组,都可以方便的解决你的问题
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

Navicat itself does not store the database password, and can only retrieve the encrypted password. Solution: 1. Check the password manager; 2. Check Navicat's "Remember Password" function; 3. Reset the database password; 4. Contact the database administrator.

Create a database using Navicat Premium: Connect to the database server and enter the connection parameters. Right-click on the server and select Create Database. Enter the name of the new database and the specified character set and collation. Connect to the new database and create the table in the Object Browser. Right-click on the table and select Insert Data to insert the data.

Navicat for MariaDB cannot view the database password directly because the password is stored in encrypted form. To ensure the database security, there are three ways to reset your password: reset your password through Navicat and set a complex password. View the configuration file (not recommended, high risk). Use system command line tools (not recommended, you need to be proficient in command line tools).

Common reasons why Navicat cannot connect to the database and its solutions: 1. Check the server's running status; 2. Check the connection information; 3. Adjust the firewall settings; 4. Configure remote access; 5. Troubleshoot network problems; 6. Check permissions; 7. Ensure version compatibility; 8. Troubleshoot other possibilities.

Common errors and solutions when connecting to databases: Username or password (Error 1045) Firewall blocks connection (Error 2003) Connection timeout (Error 10060) Unable to use socket connection (Error 1042) SSL connection error (Error 10055) Too many connection attempts result in the host being blocked (Error 1129) Database does not exist (Error 1049) No permission to connect to database (Error 1000)

Steps to perform SQL in Navicat: Connect to the database. Create a SQL Editor window. Write SQL queries or scripts. Click the Run button to execute a query or script. View the results (if the query is executed).

You can create a new MySQL connection in Navicat by following the steps: Open the application and select New Connection (Ctrl N). Select "MySQL" as the connection type. Enter the hostname/IP address, port, username, and password. (Optional) Configure advanced options. Save the connection and enter the connection name.
