PathInfo () different results for multi-byte character processing in different versions of PHP

Source: Internet
Author: User

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 hereecho phpversion();print_r(pathinfo("/resources/img/stock/wxb001/美景.png")); 输出:5.6.4-2Array(    [dirname] => /resources/img/stock/wxb001    [basename] => 美景.png    [extension] => png    [filename] => 美景)但是在php5.3.3版本中<?php// your code goes hereecho phpversion();print_r(pathinfo("/resources/img/stock/wxb001/美景.png")); 输出:5.3.3Array(    [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/wxb001echo $file_basename// 美景.pngecho $file_name; // 美景echo $file_extension; // png



From for notes (Wiz)



PathInfo () different results for multi-byte character processing in different versions of PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.