global reference


Ok, so let’s say I have a webpage, and all the images are coded as

Is there a way to use PHP to set a global reference.

So let’s say the website is at
then those images are expected to be stored at

Is there a way to globally set it so it looks for those images at

That is, make the website use as it’s reference
instead of


Well in html you can set the BASE REFERENCE using the tag. Then anything not explicitly declared would default to this as a base reference

Using as a base refernce
would get you the header image of this site (regardless if BASE is used or not, and regardless of the page it’s called from.
would attempt to get (if it existed)

So this would be one way to do it WITHOUT php.

HOWEVER, you could always set a variable in your code and use that every time you call an image.

$ImageDir = "";


echo '<img src="'.$ImageDir.'image.ext">';

That way the if the Directory changes you only change one variable (Which could be put in a “STATIC” Declaration and included)

Sponsor our Newsletter | Privacy Policy | Terms of Service