I use some constants to define paths to specific directories on a website that I'm building, like this:
define("ROOT_PATH", "http://website.com/");
define("IMAGES_DIR", ROOT_PATH . "images/");
and I usually use them like this:
echo "<img src='" . IMAGES_DIR . "some_image.jpg' />";
now I want to know if there is any difference between
define("ROOT_PATH", "http://website.com/");
and
define("ROOT_PATH", "/home/username/public_html/");
and which one of them should I use? And why?
You can't really use the following:
since it will try to load
which you don't really want.
Using
will try to fetch
which is what you want.
You should use
If you use:
In client side,The image src:
If you use:( Just for local file system )
The image src:
the difference is that html won't recognize full paths on images or src attributes... but you can use this
Or you can use a php function to convert "ROOT_PATH" based on the getenv("SCRIPT_NAME")