Bug #1535: isset() with trinary operator implicitly declares array variable
| From: | walton at nordicdms dot com | Date: | Mon, 14 Jun 1999 06:26:52 +0000 |
| Subject: | Bug #1535: isset() with trinary operator implicitly declares array variable | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-6945@lists.php.net to get a copy of this message | ||
From: walton@nordicdms.com
Operating system: Any
PHP version: 3.0.7
PHP Bug Type: Misbehaving function
Bug description: isset() with trinary operator implicitly declares array variable
In bug #1269, Zeev says:
> There aren't too many exceptions to this case, basically, only
> three special functions may reference a variable without causing
> it to be implicitly declared - those are unset(), isset() and empty().
I seem to have found an instance where isset() will implicitly declare a variable. I think. Maybe
it's the trinary operator doing it. Either way, I don't think it should be happening.
# php -q
<?
echo isset($x[0]);
0
$x[0] = isset($x[0]) ? 'y' : 'n';
echo $x[0];
y
echo isset($x[0]);
1
Obviously, $x[0] should end up being created when a value is assigned to it, but that should not
happen until after the expression is evaluated to determine what value to assign. A similar script
that does not use arrays works as expected. I spent an hour trying to figure out why my script
wasn't working right when $x[0] was not set, since the code appears correct on inspection. It
just doesn't behave the same way it does with a simple scalar variable.
Dave