Let"s go to the code directly. There are the following situations: read the contents of the file test.txt, and the test.txt content is a Chinese character string: a little dripping
.$homepage = file_get_contents("test.txt");
$homepage = mb_convert_encoding($homepage, "UTF-8","GBK"); //utf-8
echo $homepage;
:
$homepage = file_get_contents("test.txt",NULL,NULL,0,1); //
$homepage = file_get_contents("test.txt",NULL,NULL,0,2); //:
$homepage = file_get_contents("test.txt",NULL,NULL,0,3); //:
$homepage = file_get_contents("test.txt",NULL,NULL,0,4); //:
$homepage = file_get_contents("test.txt",NULL,NULL,0,5); //:
$homepage = file_get_contents("test.txt",NULL,NULL,0,6); //:
what is puzzling now is what is the meaning of the last two parameters? How did it come out and it turned out to be at a loss? If it is an English string I understand, is the last parameter the length or the number of bytes? In my code, it seems that neither the length nor the number of bytes (Chinese is 3 bytes under utf8, and it has been determined that my code is utf8) does not correspond to the result.