RE: [PHP] == vs = should generate a warning or error -- was: Why won't this work? From: Daevid Vincent (daevid <email protected>)
Date: 07/19/02

Wow, that should have been a quiz. I can't believe how many people
missed the == vs = thing and had all these elaborate answers. *grin*

Which brings me to my point. Rasmus or any other PHP duder out there --
what are the possibilities of adding a config option in php.ini to WARN
or ERROR when you try to use = instead of == in conditional checks like
that.

I can't tell you the number of minutes/hours wasted debugging code that
turned out to be that stupid mistake. While it's handy to use an
assignment in the conditional part, it can easily be done otherwise and
I for one would be glad to never use it to save me valuable time
tracking that down. Most other languages don't allow it.

DÆVID.

> -----Original Message-----
> From: Rasmus Lerdorf [mailto:rasmus <email protected>]
> Sent: Friday, July 19, 2002 12:27 AM
> To: John Wulff
> Cc: php-general <email protected>
> Subject: Re: [PHP] Why won't this work?
>
>
> You need == instead of = there
>
> On Fri, 19 Jul 2002, John Wulff wrote:
>
> > Any ideas on why this won't work? It will only
> > include("inc/entrance.php") It never, no matter what the value of
> > $mode, displays collection.php.
> >
> > <?php
> > $mode = "entrance";
> > if ($mode = "entrance") {
> > include("inc/entrance.php");
> > }
> > else if ($mode = "collection") {
> > include("inc/collection.php");
> > }
> >
> > ?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php