Home >Backend Development >PHP Tutorial > 为什么fwrite以后,fread不出来东西呢
为何fwrite以后,fread不出来东西呢。
$file = 'test.txt';
$fileHandle = fopen($file,'w+');
fwrite($fileHandle, 'Newly inserted text');
$fileContents = fread($fileHandle, filesize($file));
echo $fileContents;
fclose($fileHandle);
The manual says that if the w+ option is specified then the file is opened for reading and writing. From what I understand this means that I should be able to read from the file after writing to it. But the code above displays nothing after writing to the file. The file is chmodded 777. Can someone please explain to me why this is so :D
同问,为啥呢。
以w+模式打开,应该是可读,
可为何fwrite以后,fread不出来东西呢。