Okay, lets say I have the following folders
~/public_html/ - root www folder
~/public_html/inc - php includes
~/public_html/images - images
~/public_html/products - products etc
~/public_html/support - support etc
~/public_html/support/product1 - support for product 1
My question is, whats the best way to deal with include() and img src=""
For example. Lets assume I have an image called logo.jpg im the images folder.
In my php file, I do:
<img src="images/logo.jpg">
This will work, but if I need to move the file into a sub-folder I'll have to add a ../ in front of images to get it working again
<img src="/images/logo.jpg">
This will work, but only assuming my site is on a domain. For example
http://www.mydomain.com/index.php (it will then be able to find the image)
but, testing locally for example
http://localhost/~mysite/index.php
it won't be able to find the image, because it will be looking for it at http://localhost/images/logo.jpg
Whats the best way to deal with this so I can test my site locally and remotely without editing all the URLs each time. The same applies to include(), including .css style sheets, and .js files.
Cheers,
James.