Home > Article > Backend Development > Solution to an incompatibility problem between PHP4 and PHP3_PHP Tutorial
There are some incompatibilities between PHP4 and PHP3, but this is mainly due to the different settings in PHP.ini
in PHP4. These changes are mainly to improve the efficiency of PHP4.
Among the changes, the setting of track_vars usually makes the old PHP3 program no longer able to
run, because the value of track_vars is set to off in the extended settings of PHP4
In such old PHP3 program You cannot directly use GET, POST, and COOKIE to transfer
variables from the previous page.
I have a simple solution here. You don’t need to set track_vars to on.
But this is just a temporary solution. In the future, everyone will still use $HTTP_GET_VARS,
$HTTP_POST_VARS and $HTTP_COOKIE_VARS. It is better to read these variables.
The following is a simple program that you can add to each page that needs to read the variables of GET, POST, COOKIE
, and you can directly reference these variables.
get.variable.inc.php
if(isset($HTTP_POST_VARS))
{
while ( list( $key, $val ) = each( $HTTP_POST_VARS ) )
{
$$key = $val;
}
}
if(isset($HTTP_GET_VARS))
{
while ( list( $key, $val ) = each( $HTTP_GET_VARS ) )
{
$$key = $val;
}
}
if( isset($HTTP_COOKIE_VARS))
{
while ( list( $key, $val ) = each( $HTTP_COOKIE_VARS ) )
{
$$key = $val;
}
}
?>
Please give me your advice!