note 72132 deleted from language.variables.scope by colder
| From: | colder@php.net | Date: | Thu, 04 Jan 2007 10:15:20 +0000 |
| Subject: | note 72132 deleted from language.variables.scope by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-121274@lists.php.net to get a copy of this message | ||
Note Submitter: undefinedgeek113 at gmail dot com
Reason: in docs
----
Just an important note: When you call a function in your script, the function has its own
independent variable set and will ignore any variables set outside the function.
<?php
$a = 1;
function foo() {
echo $a;
}
foo(); // shows nothing
?>
Make sure to import all the variables needed in the function declaration.
<?php
$a = 1;
function foo($a) {
echo $a;
}
foo($a); // shows 1
?>