How to solve the garbled file name created by php
Today, I will talk to you about how to create file name garbled php, many people may not know, in order to let you know more, Xiaobian summarized the following content for you, I hope you can harvest according to this article.
php create file name garbled solution: 1, create a PHP sample file;2, through the "rename ('a.zip', iconv ('UTF-8','GB2312//IGNORE', 'Chinese a.zip');" method modified to Chinese file name.
Operating environment: Windows 7 system, PHP7.1, Dell G3 computer.
What about php creating file names?
php generated Chinese file name will become garbled, should be resolved like this
PHP now has a lot of libraries, will generate files, such as generating zip files, generating two-dimensional codes and so on. These libraries are great to use, but once you generate a filename with Chinese, you're likely to get garbled.
Question:
The generated Chinese file name will become garbled
Solution:
Use functions: iconv(), rename()
When generating file names, directly generate English names, such as:a.zip, c.zip, etc. Then, use php's function rename to move files,
rename('a.zip',iconv('UTF-8', 'GB2312//IGNORE', ' Chinese a.zip'));
Ignore means to ignore errors in conversion. Without the ignore parameter, all strings following this character cannot be saved.
After reading the above, do you have any further understanding of how php creates file name garbled? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.