Logo

Making PHP4 work on PHP5 (register globals)

Posted under » PHP on 1 November 2009

The older PHP version 4 uses register globals directive set to "on". It is better that you avoid those and use super globals which look like

Avoid those that look like

These functions has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this functions is highly discouraged.

So what if you don't have time to change your existing codes to PHP5? You can either enable register globals to on in your PHP.ini although it is not recommended. If you use Apache, you are in luck because with .htaccess you can decide which directory have register globals turned on. Create a .htaccess on the said folder eg.

php_flag register_globals on
Order allow,deny
Allow from all

This still won't work if your apache is not configured to allow this. So you have to add this permission on your apache config to allow .htaccess to work on the folder. eg.at "www/oldshit"

‹Directory /www/oldshit/›
    AllowOverride All
‹/Directory›