If my host install new version of PHP, and I can't set register_global = on. Can I set it in my script?
| SitePoint Sponsor |


If my host install new version of PHP, and I can't set register_global = on. Can I set it in my script?
I live in Thailand. My English grammar not well.
Try
ini_set("register_globals",1);
or
ini_set("register_globals",0);
Those should work. check out http://www.php.net/manual/en/function.ini-set.php for help.
- the lid is off the maple syrup again!





You can emulate register_globals by using this at the top of your script,
Although, I wouldn't recommend that, it could result in serious security problems for you.PHP Code:extract($_ENV);
extract($_GET);
extract($_POST);
extract($_COOKIE);
extract($_SERVER);
Paul
itsource, didn't you have a thread about this a few days ago?
http://www.sitepointforums.com/showt...threadid=58017
again i say, just use the proper arrays. register_globals will not be around forever, so why would you write code that relies on it?
- Matt
Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
"Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR
the doc's right itsource
we did reply to you in that post and this: "register_globals will not be around forever, so why would you write code that relies on it?" probably sums up what you should do...
and nathan you can't set the register_globals flag using ini_set()... read the reference link you gave...
Yes you can.
register_globals "0" PHP_INI_ALL
PHP_INI_ALL 7 Entry can be set anywhere
Right off the page.
Last edited by notepad_coder; May 2, 2002 at 00:30.
- the lid is off the maple syrup again!
woah apologies there on my part notepad_coder
i was refering to my downloaded copy of the PHP manual... prolly version 4.1.0... and it says there PHP_INI_PERDIR|PHP_INI_SYSTEM instead of ALL... they must have changed it in view of scripts needing register_globals=on... prolly pressure from users for an easy way to set register_globals=on now that most new php installations (4.2.0) would have it off by default
He he, a lot of people I asked about it didn't think you could do it and one person said it might not work because a lot of servers are in seafe mode.
- the lid is off the maple syrup again!


as DR_LaRRY_PEpPeR says, Sorry that I post this topic 2 times, I forgot that I post it before.
I think if I use script that rely on register_global = on before, So when it off, I don't need to change my code.
In php script, if I check all input before process anything.
I think not need to use register_global = off. Is I think correct?
Last edited by itsource; May 2, 2002 at 05:35.
I live in Thailand. My English grammar not well.
have you done it? i'd be very interested if you have.Originally posted by notepad_coder
Yes you can.
register_globals "0" PHP_INI_ALL
PHP_INI_ALL 7 Entry can be set anywhere
Right off the page.
it can't be done. the manual page for ini_set() has a lot of errors on it for what can be set where.
i said it in itsource's other thread, register_globals has done its thing before your script even starts running; your script can't change it. redemption's copy of the manual that said `PHP_INI_PERDIR|PHP_INI_SYSTEM' is correct.
believe me, if you could turn register_globals off in a script, i'd have it in every one of mine in an instant.
another example; the page says magic_quotes_gpc is `PHP_INI_ALL'... WRONG! just like register_globals, magic_quotes_gpc has already been done before the script even starts. nothing your script can do about it.
Bookmarks