Hello, I have a question about php file processing. I wrote the upload code to experience fread(development and fgetc(development, the content of the file test.txt is the thisisatestfile.txt file encoded in UTF-8 format {code ...} the above code can obtain the first character t, such... hello, I have a question about php file processing.
I wrote the upload code to experience fread(upload and fgetc(upload, the content in the test.txt file is this is a test file. txt file encoded in UTF-8 format
The above code can get the first character t. If fread's second parameter is smaller than 4, nothing can be read!
So the fgetc () below is also blank content.
Content not retrieved
My computer is a windows system
How should we understand the second parameter of fread () and a character in fgetc?
Is it because of the file encoding format?
How Should php handle the file encoding format?
Thank you!
Reply content:
Hello, I have a question about php file processing.
I wrote the upload code to experience fread(upload and fgetc(upload, the content in the test.txt file is this is a test file. txt file encoded in UTF-8 format
The above code can get the first character t. If fread's second parameter is smaller than 4, nothing can be read!
So the fgetc () below is also blank content.
Content not retrieved
My computer is a windows system
How should we understand the second parameter of fread () and a character in fgetc?
Is it because of the file encoding format?
How Should php handle the file encoding format?
Thank you!
I have tried both methods, and I have no problem with the test. My mac. Therefore, the relationship between system file encoding should be slightly determined at the beginning.
In addition, there is a warning in fread's official documentation:
Warning: 'B' must be added to the mode parameter of the fopen () function when a file is opened on a system (such as Windows) that distinguishes binary files from text files '.
At the same time, the fgetc official document prompts:
Note: this function can be safely used for binary objects.
Solution: a prompt is displayed in the document.