PHP Includes<

liunx

Guest
Hi, just wondering if this is my server or php includes as a whole.

Basically, when including php files using
<?php
include("foo.php");
?>
it works fine.

But when the file which i am including is in a seperate folder from the file which it is being included in to it does not work. EG.
<?php
include("/foo/foo.php");
?>

Why doesnt this work? Instead i have to have my include files in each folder therefore not using php includes as they should because i still have to update 5, 6 or more files in each folder (sometimes around 10 folders).

Is this the server which needs configuring or is it how php includes work?

Thanks
JamieYou would be best using your document root for this. First, open a PHP file then type...


<?php echo $_SERVER['DOCUMENT_ROOT']; ?>


Save this and upload to your server.

Then copy this and paste it into your function, so for example if my root was /home/users/damaster/public_html/ then it would go into my function like so...


<?php
include("/home/users/damaster/public_html/foo/foo.php");
?>


Good luck!Thanks for that. Still slightly confused.

Does:

<?php echo $_SERVER['DOCUMENT_ROOT']; ?>

go in a file of its own or in a current php web page and if so where in the web page?

Thanks
JamieDoesnt matter. I managed to figure it out after messing with it for a while. Thanks for your help.

Jamiejust do this

<?php
include($_SERVER['DOCUMENT_ROOT']."/foo/foo.php");
?>

:POh yeah silly me :D After looking through my things I saw that I used this method.
 
Back
Top