The Phpinfo () function is unable to process multibyte characters in the lower version of PHP while processing the path, the difference between php5.3 and php5.6 is tested here
1234567891011121314151617181920212223242526272829303132 |
<?php
// your code goes here
echo phpversion();
print_r(
pathinfo
(
"/resources/img/stock/wxb001/美景.png"
));
输出:
5.6.4-2
Array
(
[dirname] => /resources/img/stock/wxb001
[
basename
] => 美景.png
[extension] => png
[filename] => 美景
)
但是在php5.3.3版本中
<?php
// your code goes here
echo phpversion();
print_r(
pathinfo
(
"/resources/img/stock/wxb001/美景.png"
));
输出:
5.3.3
Array
(
[dirname] => /
var
/www/www.shima.jp.net/resources/img/stock/wxb001
[
basename
] => .png
[extension] => png
[filename] =>
) Also, basename () in php5.3 filters out multibyte characters echo basename ('/resources/img/stock/wxb001/view. png ')//output:. png |
The following method can be used in the lower version to implement multibyte character processing
12345678910111213 |
<?php
// your code goes here $file = '/resources/img/stock/wxb001/view. png ';$file_dir = dirname($file
);
$file_basename = substr(strrchr($file, DIRECTORY_SEPARATOR), 1)
;
$file_name =
substr
(
$file_basename
, 0,
strrpos
(
$file_basename
,
"."
));
$file_extension =
end
(
explode
(
"."
,
$file_basename
));
echo $file_dir
;
// /resources/img/stock/wxb001
echo $file_basename
;
// 美景.png
echo $file_name
;
// 美景
echo $file_extension
;
// png
|
From for notes (Wiz)
PathInfo () different results for multi-byte character processing in different versions of PHP