Results 1 to 12 of 12
Aug 17, 2012, 18:28 #1
Are there downsides to using $_SERVER['SERVER_NAME'] for base URLs?
Hoping some of you PHP ninjas can shed some light on this.
I'm currently working between localhost and a remote web server.
What I'm trying to do if possible is set a server independent base url for
my image, css, js directories.
What I have in mind is to set something like:
$baseURL = $_SERVER['SERVER_NAME'];
Then I can just reference the aforementioned resources using the variable.
My thinking is that on localhost, the baseURL variable will return well...
localhost and on the remote server, it will return something like mysite.com.
So in a nutshell, I won't need to maintain a set of definitions for localhost and
another for the remote server.
My main question is, is this even good practice? I've done a bit of research and
have come across articles that mention possible security issues but they all fall
short of outright condemning this practice.
I'd greatly appreciate your opinion on this.
Also if you can shed some light on how you'd approach this problem, I'd be much
obliged, I'm a PHP noob here trying to bring myself up to speed as fast as possible.