global reference

Hi,

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
http://www.mysite.com/bob
then those images are expected to be stored at
http://www.mysite.com/bob/dir/

Is there a way to globally set it so it looks for those images at
http://www.myothersite.com/jon/dir

That is, make the website use as it’s reference
http://www.myothersite.com/jon
instead of
http://www.mysite.com/bob

Thanks

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

Example;
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 http://mysite.com/bob/dir/hed_phphelp.png (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 = "http://mysite.com/bob/dir/";

// SOME OTHER CODE

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