Coding Practice: Use global $var or pass in by refernce
| From: | Mark Steudel | Date: | Fri, 03 Mar 2006 18:46:33 +0000 |
| Subject: | Coding Practice: Use global $var or pass in by refernce | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-231405@lists.php.net to get a copy of this message | ||
I was wondering what the general rule on using the global driective versus
passing in a variable by reference, why you should or shouldn't, etc.
e.g.
function ()
{
global $db;
$res =& $db->query( "SQL");
}
or
function ( &$db )
{
$res =& $db->query( "SQL");
}