PHP & include_path

software development


Hello all,
I’m new to php and trying to create and write a file at root level.

I used the .pcgi file extension for the php file and also used:

when I try to create and open the file with:
$thisfile= fopen("$DOCUMENT_ROOT/…/counter/counter.txt",“w+”);

I get this error:
Warning: Failed opening ‘/home/user/’ for inclusion (include_path=’.’)

when I try with:
$thisfile= fopen($_SERVER[‘DOCUMENT_ROOT’]."/counter/counter.txt");
I get a php error.

What’s the proper way in DH to create and access that folder and file?



I have the standard DOCUMENT_ROOT function to work…
using that for reading and writing for now.

If anyone has the correct DH syntax to fopen a file at root level (using the $_SERVER[‘DOCUMENT_ROOT’], please post a sample line of code.

many thanks,


Here’s what I use, which works just fine:


Is this what you were after?



Thanks for your reply.

Correctly stated, what I really needed to do was to open a file, not include it. My mistake. After trial and error the proper syntax to open a file one level up from the root is:


Hope this helps other beginners working w/ php and DH.