Re: $_SERVER['SERVER_NAME'] in read-only.

From: Date: Thu, 29 Apr 2004 16:05:35 +0000
Subject: Re: $_SERVER['SERVER_NAME'] in read-only.
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-184960@lists.php.net to get a copy of this message
AFAIK the content of the superglobal variables cannot be changed ( even though i haven't found this in the docs i can remeber got beaten by PHP for doing so :-) ) Back to the problem ( if existent ): If you don't do stuff like '$_SERVER['SERVER_NAME'] = xxxx;' inside your script you won't run into trouble - I know some ppl like to use such strange work-arounds ;-) Otherwise using define ( 'SERVER_NAME' , $_SERVER['SERVER_NAME'] ); right at startup will usually solve your problem ( as workarounds will most likely kill other scripts if the SERVER_NAME is diffrent :-)) -- red [...]
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 [...]


« previous php.general (#184960) next »