I've stumbled upon the following pecularity:
$handle = fopen(realpath("../folder/files.php"), "r");
can't read a file, but as soon as I remove php tags from the file,
it becomes readable and my scripts prints non-empty file content on the page.
Also, file.php is never ever executed, so I wonder why it is the problem.
I guess somehow Apache or PHP doesn't let read files containing php tags PHP as just text.
How can I enable it for my particular file (course doing it globally would be unsecure)?
Using PHP 5.2.x and Apache 2.0
Best Solution
I got it. I was using Google chrome to debug the page, and I realized that when viewing the source, Chrome hides PHP tags for some reason. I ran the same test on Firefox, and viewing the source proved that everything was okay.
Here are the test details:
Code:
File to be read (test.php):
Rendering (on both Chrome and firefox):
View source (using firefox):
View source (using Chrome - source of my mistake):