Re: Question on functions

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

 



Yeah the global stuff I understand and can use fine. What I would like more information about is the use of arguments to functions i.e.
function( $user, $pass, $db ) {
$db = @mysql_connect( $user, $pass, $db );
}


I understand parts but googling for the proper use of functions in php hasn't gotten me anywhere...

Sebastian Mendel wrote:
Jason wrote:

Could you give me a good example of the tip you recommend or point me to a good tutorial on it?


$GLOBALS holds all variables defined in main(), main() meaning outside any function or class

//main()
$my_var = 'test';

function myFunction()
{
    echo $GLOBALS['my_var'];

    // is the same as:
    global $my_var
    echo $my_var;

    // 'global' just creates a local reference to the global variable
    // global $my_var; is the same as:
    $my_var =& $GLOBALS['my_var'];
    echo $my_var;
}





--
Jason Gerfen
Student Computing
Marriott Library
801.585.9810
jason.gerfen@xxxxxxxxxxxx

"And remember... If the ladies
 don't find you handsome, they
 should at least find you handy..."
             ~The Red Green show

--
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