What should I do if the Chinese file name of fopen under PHP is garbled?

coldplay.xixi
Release: 2023-03-02 18:54:01
Original
3189 people have browsed it

Solution to the garbled Chinese file name in fopen under php: First encode the file name, the code is [$fileName = iconv('UTF-8', 'GBK', $fileName)]; then save the original Chinese file name; finally, create the file through file name encoding.

What should I do if the Chinese file name of fopen under PHP is garbled?

Solution to the garbled Chinese file name in fopen under php:

Encode the file name.

'; if(file_exists($fileName)){ echo 'hhhhh'; } ?>
Copy after login

Result:

What should I do if the Chinese file name of fopen under PHP is garbled?

But look at the file name output on the page:

What should I do if the Chinese file name of fopen under PHP is garbled?

So when you want When outputting a file name on the page and needing to save the file, you can save the original Chinese file name first, and then create the file through file name encoding.

Related learning recommendations:PHP programming from entry to proficiency

The above is the detailed content of What should I do if the Chinese file name of fopen under PHP is garbled?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!