I used wamp myself to build a local site to learn PHP, the system is WINDOWS8, Web page is:
Coding
However, in the processing of Chinese directories and filenames garbled, search on the internet said to be used
$dir =iconv (' UTF-8 ', ' GB2312 ', $dir); Decode the directory in Chinese and then do it again, then use
$dir =iconv (' GB2312 ', ' UTF-8 ', $dir); The anti-coding is displayed.
This method is also feasible.
However, I did not expect to upload the page to the purchase of the WEB HOSTING server, there will be garbled,
Without decoding and anti-decoding operation will not appear garbled, WEB HOSTING is LINUX under the CPANEL,
I really can't figure out why this difference occurs.
Younger brother Beginner PHP, have the warrior for me to dispel the reason that this kind of problem arises?
Or is my site on my local machine not configured properly?
Reply to discussion (solution)
In fact, it is not recommended to use the Chinese directory path.
Try changing the GB2312 to GBK.
Operating system Character Set
Winodws GBK
Linux UTF-8
When the Web page character set is the same as the operating system character set, the file name does not need transcoding
If I develop a generic template for PHP, what to do, but also to determine the system set?
Yes, since it is universal, it is necessary to respond to different environments accordingly.
Can't leave the problem to the user
For example, your Chinese file name problem, it should not be simple $dir =iconv (' UTF-8 ', ' GB2312 ', $dir);
And you can do this:
In the configuration file, write to
Define (' App_charset ', ' UTF-8 ');
Define (' Os_charset ', substr (php_os, 0, 3) = = ' WIN '? ' GBK ': ' UTF-8 ');
This $dir =iconv (' UTF-8 ', ' GB2312 ', $dir);
Writing $dir =iconv (' App_charset, Os_charset, $dir);
It's universal.
can also be further
function lang (& $str) {
return $str = Iconv (' App_charset, Os_charset, $STR);
}
In the program
Lang ($dir);
$path = lang ($dir);
All can