Darren Darren - 1 month ago 10
PHP Question

Include files from parent or other directory

I'm needing to include a file from the parent directory, and other sub-directories, into a sub-directory. I've done it before by simply using include('/rootdirectory/file.php'); but now it won't seem to work.

Just wondering how I can do this, thanks.

Here's my exact line:


It's giving me this error(the page still runs):

Warning: include(/forums/groups.php) [function.include]: failed to
open stream: No such file or directory in
C:\xampp\htdocs\forums\blog\posts.php on line

Warning: include() [function.include]: Failed opening
'/forums/groups.php' for inclusion
(include_path='.;C:\xampp\php\PEAR') in
C:\xampp\htdocs\forums\blog\posts.php on line 3


include() and its relatives take filesystem paths, not web paths relative to the document root. To get the parent directory, use ../


If you begin with a /, an absolute system file path will be used:

// Full absolute path...