Stephen Kay wrote:
If you are dynamically loading pages, through php, from inside a folder
that have relative links to images inside the same folder, into another
document (a template) in a different folder level, the links will be
broken.
Is there some magic trick to dealing with this, or is it just better to
never use relative links in a site that will be dynamically driven with
php?
Hi,
Well, several opinions on this subject.
my 2 cents:
Your problem manifests in many forms, also with includes.
I made it a habbit to make a config-file for each PHP-project, and make a
simple function (or constant) in there that points to eg:
- absolute path (URI) to imagedirectory
something like:
function getRootDirImages(){
return "http://www.blabla.com/images/";
}
You can do the same for includes, but it is easier to overwrite a php.ini
setting for each script named include_path.
use ini_set() for that.
If you include both above every script, you have easy acces to all your
paths.
More solutions exists, but I like this one because it is easy and clean.
Regards,
Erwin Moller