Well, I am beginning to hate PHP. I've got a file, that is perfectly readable (is_readable returns true), has 777 permission, is generally opened up by fopen, but file_get_contents is coming back false. The code is following:

$handle = fopen("tres.txt","w+");
$cnt = file_get_contents("/var/www/tres.txt");
catch(Exception $err){ echo $err->getMessage(); }
if ($handle) echo "Allright!", "<br />";
if ($cnt) echo "Good";
if(is_readable("/var/www/tres.txt")) echo " Is";

And despite the fact that I switched on all error confirming options I understood, no errors are catched, which drives me mad. Altering file road to "./tres.txt" of "tres.txt" doesn't have effect either. In which the problem may lie?

P.S. It's operate on PHP5 and apache2.

Interesting time.

fopen("tres.txt","w+"); truncates the file. Reading through it immediately after which makes no sense.

$cnt is probably not false however the empty string '' that is considered false inside a boolean context.

if ($cnt !== false) echo "Good"; would most likely output "Good".

It's not necessary to use fopen when utilizing file_get_contents. Remove fopen.