RE: [PHP] A quick question

From: Date: Wed, 11 Oct 2000 22:12:47 +0000
Subject: RE: [PHP] A quick question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-19717@lists.php.net to get a copy of this message
On Wed, 11 Oct 2000, richard wrote: > according to page 110 of "Proffessional PHP programming" (wrox press) the > operator " ==" means equal to... > while the operators "=" and "!=" are right associative assignments... > > therefore using the logic if ($val =="abc") { means if the value of $val is > equal to "abc" then ... > while if ($val = "abc") means assign the value of abc to $val and then > execute the insides of the curly braces. This will ALWAYS be true in your > example..... > > then again, its only a book ;-) - and we are all human ! Indeed we are only humans, and I have no idea on what you are refering to, since I told you exactly what you are telling me. The "fix" that you sent was : ====//==== try this : if (!($value="206.20.254.3")) { echo "\$var = $value<BR>"; } you must 'escape' the "$var" as it will think it is a variable not a string, and I have found that "!=" is unreliable ! richard ====//==== You see ? Only one "=" there means that you will be always assingning "206.20.254.3" to $value, instead of checking the equality using two equals "==", which is the correct way to go. But I can go even further, doing ( $value != "blah" ) and ( !($value == "blah") ) is the same thing, or at least is on my "reliable !=" operator :) Joao -- Joao Prado Maia Web Developer Kefta, Inc. T: (415) 391-6881 ext 8008 F: (415) 391-7079

« previous php.general (#19717) next »