Re: Question on functions

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

 



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



--
Sebastian Mendel

www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetime        www.sf.net/projects/phptimesheet

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