![]() |
Does CI unset variables in $GLOBALS ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Does CI unset variables in $GLOBALS ? (/showthread.php?tid=48491) |
Does CI unset variables in $GLOBALS ? - El Forum - 01-18-2012 [eluser]shanebonham[/eluser] I'm sort of new to this, so my understanding may be flawed, but outside of CI, this seems to work: Code: $foo='bar'; 'bar' will be echoed. However, if I put the above in a CI controller's method, it doesn't work (I get an 'undefined index' notice). I know CI unsets some stuff, and I thought that was all handled by _sanitize_globals() in the Input class, but from what I can tell, it leaves $GLOBALS alone. I also see this in the docs: "Destroys all global variables in the event register_globals is turned on." Where does this happen? Does CI unset variables in $GLOBALS ? - El Forum - 01-18-2012 [eluser]shanebonham[/eluser] It's worth pointing out that what I was originally trying to do was assign $foo outside of a function, and then use it inside the function after setting `global $foo;` (which didn't work). Does CI unset variables in $GLOBALS ? - El Forum - 01-19-2012 [eluser]InsiteFX[/eluser] $GLOBALS is truned off by default in your php.ini file for security reasons! They do not use it anymore... Does CI unset variables in $GLOBALS ? - El Forum - 01-19-2012 [eluser]shanebonham[/eluser] Do you have a source for $GLOBALS being deprecated? I get output from print_r($GLOBALS). I just don't get any of my variables. Does CI unset variables in $GLOBALS ? - El Forum - 01-19-2012 [eluser]WanWizard[/eluser] http://php.net/manual/en/security.globals.php This is the age of OOP. Do not use globals. not now. not ever. If your app requires globals, you've designed it wrong. Does CI unset variables in $GLOBALS ? - El Forum - 01-20-2012 [eluser]shanebonham[/eluser] Thanks for the advice, but I'm just trying to understand CI better. Are you sure that the deprecation of the register_globals directive also means the deprecation of the $GLOBALS array? That isn't what the docs seem to be saying. Does CI unset variables in $GLOBALS ? - El Forum - 01-20-2012 [eluser]WanWizard[/eluser] I don't think $GLOBALS will disappear soon, as that would mean the global keyword will no longer work too, which will break a lot of applications (including CI). The rest of my statement still stands. Using globals is evil. period. |