file_get_contents returns an empty string that is 354 bytes long
I'm trying to read the contents of a file and simply getting an empty string. The file exists on the serv开发者_开发技巧er.
I've tried some test with the following code and get the true to display:
$filename = "includes/blah.php";
$filecontents = file_get_contents($filename, FILE_USE_INCLUDE_PATH);
if ($filecontents === false) {
echo(":FALSE:");
}
else {
echo(":TRUE:");
}
var_dump($filecontents);
The dump displays "string(354)" which is the correct size of the file.
What am I doing wrong?
Check
- permissions on file (r for webserver)
- error reporting at server
- wrap output with htmlentities()
(add error_reporting(E_ALL) on top of your script)
regards,
///t
精彩评论