Re: Scope of variables in php
| From: | Angelo Dipierro | Date: | Fri, 04 Aug 2000 07:47:04 +0000 |
| Subject: | Re: Scope of variables in php | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-10085@lists.php.net to get a copy of this message | ||
> There is no block scope in PHP. Your if condition must be inside a
> function.
Ok, I thought that. I have written a great deal of code and I have
never had that problem. Anyway I have a piece of code that behaves
exactly that way and that puzzles me :)
Let me explain. I have something like
<?php
[...some database query...]
if ([query ok])
$myVar = [some_field]
echo "<!-- $myVar -->"; // just to be sure
?>
[... some html ...]
<?php
echo "<frame src='".$myVar."...";
?>
after this, the first echo works fine, while the second echoes
nothing as if $myVar was undefined.
Is this a new feature in php4 ? Is this a bug in the windows version
of php (running as a cgi, IIS4 + WinNT server) ? I think I'll
double-check my code but I'm pretty sure there's something strange...
Thanks...