Avoiding problems caused by register globals in php

by on Jun.15, 2005, under Tech Tips

So here’s the situation, you have a fully working website that was written with register glabals on or just on an earlier copy of php. You either change host or your host upgrades and you find that register globals is off and you cant have it on just for your site.

The obvious solution is to rewrite your site to use $_POST and the other super variables, but sometimes this just isnt worth the effort.
The method I’ve just discovered (it took long enough to find) is a standard feature of php is to use the extract function, this function will create a variable for every key in an array so using extract($POST); will crate a variable for every key in the post data, this is just like you’d expect from having register globals on.


Comments are closed.