note 31954 added to functions
| From: | Storm at rack1 dot php dot net | Date: | Sat, 10 May 2003 00:55:40 +0000 |
| Subject: | note 31954 added to functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47804@lists.php.net to get a copy of this message | ||
I think it worthy of noting (for noobies such as myself):
You can define access to a global variable before it is defined when defining a function as long as
the variable is defined before the function is called. This had me baffled for a few hours til I
tried it out...lol. Here's a quick example:
Perfectly valid:
-------------------------
function hello() {
global $hi;
echo $hi;
}
$hi = 'Hi There!'; // Var defined after function is defined
hello();
-------------------------
I know most of the Gurus persay already knew this, but I didn't! :p This helps ;-)
--
http://www.php.net/manual/en/functions.php
http://master.php.net/manage/user-notes.php?action=edit+31954
http://master.php.net/manage/user-notes.php?action=delete+31954
http://master.php.net/manage/user-notes.php?action=reject+31954