note 7997 modified in Variable scope by ronabop
| From: | ronabop@php.net | Date: | Fri, 25 Aug 2000 08:51:50 +0000 |
| Subject: | note 7997 modified in Variable scope by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-3177@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/variable-scope.php