Forum Moderators: coopster
My question is, how do you guys handle this? I'm pretty sure you "define" the absolute link to a users "home" location, and go from there I guess? Where do you store this defined variable at, the index page?
I'm curious to hear what you users do with this situation that occurs everytime you code.
I run the same site in 3 different locations 'dev' on a vmware server at home, 'live' and 'test' are on the hosted server. 'Test' runs under a sub directory of the live site.
I have a url() function that I pass all url's through, so if I need to make a change its only in one place.
Usage example:
$linksurl=url('links');
IsTest() is a function that returns TRUE if the page is running on the Test server (as it runs in a sub-directory of Live, there are some exceptions to deal with).
$_SESSION['homedir'] contains the directory name if any (on Dev server, its the project name, on Test, its 'dev').
function url($url='')
{ // check for 'photos' or 'images', convert to absolute url if found
if (IsTest())
{
if (substr($url,0,7)=='images/' ¦¦ substr($url,0,7)=='photos/')
return('http://www.MYSITEURL./'.$url);
}
return($_SESSION['homedir'].$url);
}
include '../filename.php';
include '../directoryname/filename.php';
And Welcome to WebmasterWorld there, Deab.