开发者

file_get_contents returns an empty string that is 354 bytes long

开发者 https://www.devze.com 2023-02-01 16:32 出处:网络
I\'m trying to read the contents of a file and simply getting an empty string. The file exists on the serv开发者_开发技巧er.

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

  1. permissions on file (r for webserver)
  2. error reporting at server
  3. wrap output with htmlentities()

(add error_reporting(E_ALL) on top of your script)

regards,

///t

0

精彩评论

暂无评论...
验证码 换一张
取 消