During our recent Linux server migration task, we faced the following issue -
Some websites built on older versions of PHP 5.3.0 or earlier could not fetch several database records. After some investigation, we found that problem was with Register_globals ().
Register_globals () is DEPRECATED in PHP 5.3.0 and REMOVED in PHP 5.4. The customer had used Register_globals=ON in their code.
If you set Register_globals=ON in your code, values submitted through a form via POST or GET will automatically be accessible via a variable in the PHP script named after the input field's name.
For example:
If you have a URL such as
http://www.xyz.com/var_name.php?user_id=10
You'll automatically have $user_id = 10 in PHP.
The customer was using such variables in their SQL queries.
In our new Linux server, the target PHP version was set to PHP 5.4, in which Register_globals is removed. Hence, SQL queries could not fetch the passed parameters.
As a resolution, we advised the customer to emulate register_globals by using extract in global scope as follows -
extract($_REQUEST);
Or
Create an independent function as follows –
function xyz()
{
foreach ($_REQUEST as $key => $val)
{
global ${$key};
${$key} = $val;
}
}