php rename Chinese garbled solution: first open the corresponding PHP code file; then change GB2312 to GBK through the "iconv("GBK","UTF-8",$a);" method .
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
php windows rename Chinese error
The rename() function can rename files, directories, etc., but pay attention to the encoding of the destination and starting address.
For example: My PHP file encoding is UTF-8, but the default Chinese encoding in the WINDOW system is GBK, so I should write like this:
rename(iconv('UTF-8','GBK',$dir.$filename), iconv('UTF-8','GBK',$dir.$newFileName));
OK, Perfect
When using the iconv function to convert Chinese character strings in php, the following error is prompted:
Notice: iconv() [function.iconv]: Detected an illegal character in input string in a.php on line 796
The error statement is as follows:
iconv("GB2312","UTF-8",$a);
The solution is to change GB2312 to GBK:
iconv("GBK","UTF-8",$a);
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What to do if php rename Chinese garbled characters. For more information, please follow other related articles on the PHP Chinese website!