Home  >  Article  >  Backend Development  >  Solution to garbled characters and Sessions verification problems in PHP! _PHP Tutorial

Solution to garbled characters and Sessions verification problems in PHP! _PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:48:26981browse

When Chinese or other language characters are read as garbled characters in a PHP script, first check whether your file format is saved in UTF8 encoding format. If not, please use UltraEdit... and other tools that support UTF8 conversion to convert it. It is best not to use MS Notepad to directly save as conversion. I made this mistake at the beginning mistake. If you are editing in Dreamweaver, please follow: Edit---》Preferred Parameters---》Create a new document and set the language to UTF8 encoding.

Regarding the SESSION verification issue: At first, all my documents were written in GB2312. Later, a website required UTF-8 encoding, so I opened some of my files with MS Notepad and saved them as UTF. -8 encoding, I didn’t expect that he would add a signature (BOM) to the file header of the script program, so I converted it directly and the result was an error: Cannot send session cookie - headers already sent by ...

After debugging for a long time, I found three solutions:

The first is as mentioned just now, convert the source file using Dreamweaver or UltraEdit... and other tools that support UTF8 conversion. This is the most fundamental solution;

The second method is to add an “@” in front of the session_start() function

The third method is to open phpinfo() and see if the Output_buffering parameter is no value. If so, set it to 1

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319708.htmlTechArticleWhen reading Chinese or other language text in a PHP script is garbled, first check whether your file format is correct Saved in UTF8 encoding format. If not, please use UltraEdit...wait some...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn