Re: Coding Practice: Use global $var or pass in by refernce

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 ()
{
    global $db;
$res =& $db->query( "SQL");
}
or function ( &$db )
{
$res =& $db->query( "SQL");
}


or

function foo ()
{
    $db = & $GLOBALS['database'];
    $res = & $db->query();
}

or

function foo ()
{
    $res = & $GLOBALS['database']->query();
}

Just some more possibilities...


cheers
Jens

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux