Goldeneye Posted August 28, 2008 Share Posted August 28, 2008 Here a few questions I've had on my mind since I started using globalized variables in my script, so I figured that'd I'd ask them here. 1. How secure are globalized variables? 2. (Using the $GLOBALS[] array and the global construct) Is one method more secure than the other? 3. I read that PHP 6 is going have removed the register_globals option, does this mean the $GLOBALS[] array, and the global construct will become unusable? Link to comment https://forums.phpfreaks.com/topic/121648-a-few-questions-about-globals/ Share on other sites More sharing options...
trq Posted August 28, 2008 Share Posted August 28, 2008 1. Depends. 2. Not really. 3. No. Global variables are simply poor programming practice for many reasons, security being one, maintainability and code readability being another. Why you feel the need to use them is behond me. Link to comment https://forums.phpfreaks.com/topic/121648-a-few-questions-about-globals/#findComment-627569 Share on other sites More sharing options...
Goldeneye Posted August 28, 2008 Author Share Posted August 28, 2008 Well I use them to reduce redundancy because I re-use certain variables quite often. So instead of redeclaring them, I simply globalized them using the global $var construct. That's really all I've used them for. I read somewhere else that Globalized variable-names can be overlapped between different scripts. Like foobar.org/foo and foobar.org/bar both might have a globalized variable named $var (eventhough they are both using completely different scripts) which could cause potential problems. I don't know if that's correct, but that is what I understood from it. Link to comment https://forums.phpfreaks.com/topic/121648-a-few-questions-about-globals/#findComment-627573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.