note 69611 modified in language.variables.scope by danbrown

From: Date: Mon, 18 May 2009 01:35:33 +0000
Subject: note 69611 modified in language.variables.scope by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155556@lists.php.net to get a copy of this message
Using the global keyword inside a function to define a variable is essentially the same as passing the variable by reference as a parameter: <?php somefunction(){ global $var; } ?> is the same as: <?php somefunction(& $a) { } ?> The advantage to using the keyword is if you have a long list of variables needed by the function - you dont have to pass them every time you call the function. --was-- Using the global keyword inside a function to define a variable is essentially the same as passing the variable by reference as a parameter: somefunction(){ global $var; } is the same as: somefunction(& $a) { } The advantage to using the keyword is if you have a long list of variables needed by the function - you dont have to pass them every time you call the function. http://php.net/manual/en/language.variables.scope.php

« previous php.notes (#155556) next »