RE: [PHP] == vs = should generate a warning or error -- was: Why won't this work?

From: Date: Fri, 19 Jul 2002 22:59:12 +0000
Subject: RE: [PHP] == vs = should generate a warning or error -- was: Why won't this work?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-108596@lists.php.net to get a copy of this message
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@php.net] > Sent: Friday, July 19, 2002 12:27 AM > To: John Wulff > Cc: php-general@lists.php.net > 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"); > > } > > > > ?>

« previous php.general (#108596) next »