Home >Backend Development >PHP Problem >Can't php write Chinese characters?
php can write Chinese characters, but the encoding needs to be set. The setting method is to add the "header("Content-type:text/html; charset=utf-8");" code to the PHP page.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
php Can’t I write Chinese characters?
php can write Chinese characters, but the encoding needs to be set.
Chinese garbled characters
Just this sentence is enough
header("Content-type:text/html; charset=utf-8");
$_GET variable
contains Chinese characters The GET variable, if used in PHP, must be converted into GBK format, otherwise it cannot be displayed using the
'; //必须要转换成GBK $dirname = iconv('utf-8', 'GBK', $dirname); echo $dirname.'
'; ?>
browser
complete Example
Take directory traversal as an example
'; } } } } } read_all($dirname); ?>
Experimental effect
Recommended study: "PHP Video Tutorial》
The above is the detailed content of Can't php write Chinese characters?. For more information, please follow other related articles on the PHP Chinese website!