| 
	
 | 
 Posted by Toby A Inkster on 02/14/07 17:08 
Oliver Grätz wrote: 
 
> - Global variables in PHP are not as global as they are in other  
> languages where you can sometimes always see the global variables. Some  
> languages even have the keyword "local" to prohibit a variable from  
> becoming global. PHP instead has the "global" keyword to define a  
> variable as global. 
 
In PHP the global keyword basically pulls a variable from the global 
namespace into the local namespace. 
 
What most other languages refer to as "globals" PHP calls "superglobals". 
There's no way to define superglobals though -- PHP defines a few on its 
own (depends on your version, but in recent ones, $_POST, $_GET, $SERVER, 
$_SESSIOM, $_ENV, $_FILES and $GLOBALS) and you're stuck with them. 
 
Although I steer away from globals (in my current project, over 4000 lines 
of PHP so far, and not a single global!), sometimes I really would 
appreciate having a method of defining superglobals. Not going to happen 
though. :-( 
 
--  
Toby A Inkster BSc (Hons) ARCS 
Contact Me ~ http://tobyinkster.co.uk/contact 
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux 
 
* = I'm getting there!
 
  
Navigation:
[Reply to this message] 
 |