In my php script, I created a constant variable that defines the base url to be placed in my hyperlinks, but is it really necessary?
Here is an example of what I mean.
I have it:
// base url is only defined once and reused throughout
define("__BASE_URL","http://localhost/test1/");
print '<a href="'.__BASE_URL.'index.php?var1=open/>Open</a>';
(I have many of these distributions throughout my script.)
I tried this and it works:
print '<a href="index.php?var1=open/>Open</a>';
So how is this the right way? I noticed that the second method works even when loading images, css and javascript files.
source
share