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
- $_POST says that variables in that array come from a form.
- $_GET says that variables are passed through the URI.
- $_SESSION says that variables are in a session.
- $_SERVER['PHP_SELF'] getting server variables
Avoid those that look like
- session_register(),
- session_unregister(),
- session_destroy()
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›
