Today, when using the basename function to get the file name, it is found that if the Chinese file name returns only the empty name of the suffix (for example:. pdf)
String basename (String path [, string suffix])
Description
Give a string containing a full path to a file, this function returns the base file name. If the file name ends in suffix, then this part will be removed as well.
Method One: Follow the Web site to find the argument is that this function depends on the locale, if the multibyte name returned as null can be set by the setlocale function as follows
View Plainprint?
- <?php
- SetLocale (Lc_all, ' ZH_CN. GBK ');
- Or any of the other locales that can handle multibyte characters.
- ?>
It is best to modify the server's regional settings to solve the overall!
Method Two: Php comes with the basename function does not support Chinese, the following method is the simplest implementation.
View Plainprint?
- function Get_basename ($filename) {
- return preg_replace ('/^.+[\\\\\\/]/', ', $filename);
- }
"Go" php basename function does not support the resolution of Chinese names