RE: [PHP] PHP globals aren't really globals

From: Date: Wed, 14 Feb 2001 14:55:19 +0000
Subject: RE: [PHP] PHP globals aren't really globals
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39629@lists.php.net to get a copy of this message
>> function u want to use it. THis is not nice, what about if u >> have a form with 50 fields and want a function to validate >> all of them, u have to pass them all to the function or build >> a little piece of code to make all the $GLOBALS local right? >> Is this really the idea of global vars? > >Yes. But with regards to form variables, all you need to do is >make one variable global: > >$HTTP_POST_VARS > >it is an associative array that contains all the post variables from >the form. Make it global and just loop through it. exactly, u need to loop to an array to get the globals u want. this is not the idea of global, global is global... if it's set outside of ALL functions it should be available 'with no extra code' to ALL functions, it works that way in all programming language I'm familiar with... why not in PHP? that's what I wanna know, why globals in PHP doesn't really work like globals? . [ Christian Dechery ] . Webdeveloper @ Tá Na Mesa! . Listmaster @ Gaita-L . http://www.tanamesa.com.br

« previous php.general (#39629) next »