note 7997 added to Variable scope
| From: | niki at littlebull dot com | Date: | Wed, 23 Aug 2000 19:04:56 +0000 |
| Subject: | note 7997 added to Variable scope | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-3032@lists.php.net to get a copy of this message | ||
What needs documenting is how scoping applies to the HTML-interpolatedness of PHP.
<?
$a = 'foo';
$b = 'bar';
?>
<p>text text text plain ol' HTML text</p>
<?
echo $a . $b;
?>
So will this echo statement return "foobar" or "" ?
It turns out that the former is correct: "global" means the entire file, not just that
particular chunk of PHP within the file. Which only makes sense, given the examples of ASP and
JavaScript, but it needs saying.
http://www.php.net/manual/language.variables.scope.php