Re: Re: make global variables accessible to functions?

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

 



I have to agree with passing them as opposed to accessing them from inside
the function

Clean
$a = "whatever";
function foo($a){
    echo $a;
}

Ugly
$a = "whatever";
function foo(){
    global $a;
    echo $a;
}

Unless the variables in question are for all intents and purposes constant (
real constants can't be arrays ), ie for example configuration vars, I would
avoid making them global.

Having that said, it's your code......

[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