RE: [PHP4BETA] lates libzend update did bad things
| From: | Rasmus Lerdorf | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | RE: [PHP4BETA] lates libzend update did bad things | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-4045@lists.php.net to get a copy of this message | ||
> At 16:36 03/09/99 , Samuel Liddicott wrote:
> > > Yes. unset($var) leaves no trace of $var. Assigning $var with anything,
> > > regardless of what you're assigning it with, $undefined_var
> > > included, means
> > > $var is intact, and contains some sort of a value. It would contain that
> > > so called undefined value, but it would mean that each and every piece of
> > > code that may handle $var must be aware that in case it contains that
> > > undefined value, it must behave differently.
> >
> >In php4, what would be returned if $url was not in $urls[] ? Surely the
> >undefined value?
>
> No. It would return an empty string (true for PHP 3.0 as well).
> The PHP behavior for this is simple. The value of an undefined variable is
> an empty string. You're allowed to rely on that, and many PHP programmers
> do (I personally don't like it and prefer turning E_NOTICES on to avoid it,
> but that's the published behavior).
It does cause some problems, and I don't particularly like it either, but
the amount of internal PHP code, plus the amount of legacy PHP scripts out
there that would have to change in order to change this behaviour is
pretty staggering.
In your example, you would know the difference between an array element
that actually contained an empty string vs. an array element that didn't
exist by calling: isset($array[$index])
-Rasmus