PDA

View Full Version : register_globals?


Kayn
Fri 14th Nov '03, 1:00am
Apparantly my scripts rely heavily on this being set to "on." I learned that future builds of php will not have this option, so I need to learn how not to rely on this feature.

What do I look out for when I'm coding to avoid relying on register_globals being on?

TiLaser
Fri 14th Nov '03, 1:19am
Use super globals ($_POST, $_GET, $_REQUEST).

Kayn
Fri 14th Nov '03, 2:22am
Let's assume I've never used super globals before (because I haven't :) ), could you (or someone else) provide a quick example of super_globals as opposed to regular globals?

merk
Fri 14th Nov '03, 10:39am
If you request something via URI ->

page.php?variable=value

It gets assigned to $_GET['variable'] first. register_globals will then go through $_GET and register each variable into $variable.


POST requests -> $_POST.

If you dont want to learn how to use globals, you could just write a function that registers them ;)

TiLaser
Fri 14th Nov '03, 12:24pm
I would suggest using them though. They have the advantage of being super globals so they are accessible in any functions or classes.