Home >Backend Development >PHP Problem >What to do if php print r is garbled?
php The solution to garbled print r: first set "header("content-type:text/html;charset=utf-8")"; then unify the encoding settings of files and databases.
Recommended: "PHP Video Tutorial"
Specific questions:
php uses print_r to output garbled characters where to set the encoding
print_r($result);The result is shown as follows:
���������ȷ��
Where should the encoding be set? I want to temporarily set up the Chrome browser to view the content, but the encoding setting option is not found in version 60.
Solution:
1. Chrome no longer has this function.
If you are writing PHP, it is recommended to analyze $result first. The browser is a terminal, and you still have to check the source code in the end.
Set header("content-type:text/html;charset=utf-8") to ensure that it is not a problem with PHP output
2. First: When garbled characters appear, please encode the program: File encoding, database encoding, output encoding, etc. It is best to use uniform ones.
Secondly: The new version of chrome has removed the function of setting encoding because the frequency of use is too low. You can modify the encoding by installing an extension: Charset
The above is the detailed content of What to do if php print r is garbled?. For more information, please follow other related articles on the PHP Chinese website!