Re: $_SERVER['SERVER_NAME'] in read-only.
| From: | Jason Barnett | Date: | Thu, 29 Apr 2004 12:42:54 +0000 |
| Subject: | Re: $_SERVER['SERVER_NAME'] in read-only. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-184941@lists.php.net to get a copy of this message | ||
Vincent M. wrote:
Hello,
I am using the variable $_SERVER['SERVER_NAME'] inside a function, for example:
function check_servname() {
global $server ;
if($_SERVER['SERVER_NAME'] != $server) {
echo "NOT OK, NOT GOOD SERVER NAME" ;
exit ;
}
}
But we can modify the value of $_SERVER['SERVER_NAME'] before calling the function check_servname(). And I am looking for a the right server name not for a server name which may have been changed before calling check_servername:
$_SERVER['SERVER_NAME'] = "www.google.com" ; //before calling check_servname and $_SERVER['SERVER_NAME'] will be "www.google.com" inside the function even the server name is not "www.google.com".
Is there any way to get the server name with a variable which would be read-only ?
Thanks,
Vincent.
Agreed - constants are the way to do this. I wanted to mention that the $_SERVER variables are meant to hold values generated by your server. Of course if you really ARE google then I'm going to feel stupid for even mentioning this :)
http://www.php.net/reserved.variables
Jason