Re: Coding Practice: Use global $var or pass in by refernce
| From: | Jens Kleikamp | Date: | Fri, 03 Mar 2006 20:31:58 +0000 |
| Subject: | Re: Coding Practice: Use global $var or pass in by refernce | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-231415@lists.php.net to get a copy of this message | ||
Mark Steudel wrote:
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 () {or function foo () {global $db; $res =& $db->query( "SQL");} or function ( &$db ) {$res =& $db->query( "SQL");}
$db = & $GLOBALS['database'];
$res = & $db->query();
}
or
function foo ()
{
$res = & $GLOBALS['database']->query();} Just some more possibilities... cheers Jens