I recently updated to PHP 5.3.6 and there were some deprecated functions and INI directives. I have the following function:
function ServerVar($varName) {
global $HTTP_SERVER_VARS;
global $HTTP_ENV_VARS;
if(!isset($_SERVER))
{
$_SERVER = $HTTP_SERVER_VARS;
if(!isset($_SERVER["REMOTE_ADDR"]))
$_SERVER = $HTTP_ENV_VARS; // must be Apache
}
if(isset($_SERVER[$varName]))
return $_SERVER[$varName];
else
return "";
}
Ru开发者_StackOverflow中文版nning that function caused an error in apache log:
<b>Deprecated</b>: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in <b>Unknown</b> on line <b>0</b><br />
I modfied the code like this:
if(!isset($_SERVER))
{
$_SERVER = &$HTTP_SERVER_VARS;
if(!isset($_SERVER["REMOTE_ADDR"]))
$_SERVER = &$HTTP_ENV_VARS; // must be Apache
}
if(isset($_SERVER[$varName]))
return $_SERVER[$varName];
else
return "";
}
however the the same error still appears in apache log. What is the best way to resolve this problem?
Thank you!!
In PHP 5.3 (really, I think any version of PHP 5 or later any version of PHP newer than 4.1.0) you shouldn't ever need to use $HTTP_SERVER_VARS
or $HTTP_ENV_VARS
. Just use $_SERVER
. If that does not work, then your server needs to have it's configuration fixed; not code workarounds like this induced.
精彩评论