functions and global variables

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

 



Hello,
I've got a file with a variable declared in it. For purposes of this post:

$name = $_POST['name'];

Now a little later in the same file I have a custom function call that
outputs some information. In that information is an echo statement
outputting $name:

echo $name;

I'm wondering do I have to have $name declared as a global variable
within that function? For example:

function customFunction() {
global $name
}

I've tried it both ways and both ways it works, with and without the
global statement. I was under the impression that to be useful in a
function variables outside were not accessible.
Thanks.
Dave.

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