Globals Variable question
| From: | Terence | Date: | Thu, 04 Mar 2004 05:47:24 +0000 |
| Subject: | Globals Variable question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-179423@lists.php.net to get a copy of this message | ||
Hi All,
Can someone tell me which is better, or if there's a reason I should use one
and not the other (since both seem to work), and if this is the
correct way to access script variables inside functions (and classes):
Example 1
========
$GLOBALS['db_name']="website";
function QueryDB() {
echo $GLOBALS['var'];
}
QueryDB();
Example 2
========
$db_name="website";
function QueryDB() {
echo $GLOBALS['var'];
}
QueryDB();
Many thanks