An error occurs when reading the contents of a newly created temporary file
LIWEN
LIWEN 2017-06-14 15:08:52
0
1
1341

<?php
//Create a temporary file
$lsfile = tmpfile();

//Write data into it
$lsshuju = fwrite($lsfile, '111Here is the data written to the temporary file');

//Output writing situation
echo 'Write ' . $lsshuju . ' characters to the temporary file<br>' ;

//Output the contents of the temporary file
$shuchu = file_get_contents($lsfile);
echo $shuchu;

//Close the temporary file
fclose($ lsfile);
?>


An error is reported when reading the content. How can I read the content correctly?

LIWEN
LIWEN

reply all(1)
左手右手慢动作

What is wrong with the report

  • reply 39 characters were written to the temporary file Warning: file_get_contents() expects parameter 1 to be a valid path, resource given in /home/phpcn6peh2pwcun/wwwroot/compile.php(30) : eval()'d code on line 12
    LIWEN author 2017-06-15 09:02:41
  • reply The error reported is that the $lsfile variable is not a valid path.
    ringa_lee author 2017-06-15 09:14:49
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template