Forum Moderators: coopster
I thought i could just put a relative path for that include in any file anywhere in my root and all subfolders but i guess not. Or maybe im just doing it wrong? Because i would hate to go include("../../somefile.php") instead of just include ("somefile.php");
So I usually do my links roughly like this
$href = $_SERVER['HTTP_HOST'] . '/dir/page.php';
$include_file = $_SERVER['DOCUMENT_ROOT'] . '/dir/page.php';
You may also set the include_path [us4.php.net] directive in php.ini or .htaccess.
I think egrophobe has the best solution, and thought maybe I could help with a little clarity on link structure.
The most important thing to remember is a link with a preceding / will start at you root (or 'home') directory, while a link without the preceding / will start from where you are and go deeper into your site, an example would be:
If your location in the browser is http//yoursite.com/stuff/page.php
"my-php/file.php" would look for this location:
http//yoursite.com/stuff/my-php/file.php
This link goes deeper into the directory you are already in.
"/my-php/file.php" would look for this location:
http//yoursite.com/my-php/file.php
This link starts at the beginning, so you actually end up at the same level in a different directory.
Not sure if you need this, but thought it might help.
Justin