Does the following code make sense?:
$t_server = isset( $_SERVER ) ? $_SERVER : $HTTP_SERVER_VARS;
As I understand, $HTTP_XXX_VARS
is same with $_XXX
, except $HTTP_XXX_VARS
is deprecated. Thus, I don't understand the code above.
Is there a case that two variables are different in an old system in which $HTTT_XXX_VARS
is not considered as deprecated?
$HTTP_SERVER_VARS
and $_SERVER
are different variables (if both are set). They initially contain the same values but, being different, the changes that the script does on one of them do not affect the other.
The superglobals
($_GET
, $_POST
, $_SERVER
etc) were introduced on PHP 4.1
. The long named variables ($HTTP_GET_VARS
, $HTTP_SERVER_VARS
etc) were deprecated on PHP 4.1
and they were removed on PHP 5.4
.
PHP 5.0
introduced the configuration setting register_long_arrays
that was used to tell PHP
to create (or not) the old long-named variables ($HTTP_GET_VARS
and the rest). The setting was deprecated on PHP 5.3
and removed altogether on PHP 5.4
(together with the long-named arrays).
As you can see, between PHP 4.0
and PHP 5.4
one or both versions of these variables were available to the programmer.
The line:
$t_server = isset( $_SERVER ) ? $_SERVER : $HTTP_SERVER_VARS;
takes advantage of the new superglobal variable $_SERVER
, if available (on PHP >= 4.1
), but it falls back to the old $HTTP_SERVER_VARS
if it runs on older PHP
. It was probably written years ago, while PHP 4
was still in use on a lot of servers.
Except on the unlikely case when you are stuck with PHP 4.0
, you can safely change the above line to:
$t_server = $_SERVER;
or just use $_SERVER
instead of $t_server
everywhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With