Re: if(($mydata->address
| From: | John Taylor-Johnston | Date: | Thu, 02 Jun 2005 00:46:33 +0000 |
| Subject: | Re: if(($mydata->address | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-216187@lists.php.net to get a copy of this message | ||
Jay,
Thanks. Sth new learned :) Thought mine was working. It wasn't I guess. I received no errors. I have other scripts to revise :)
if("" = $mydata->foo) // an error is thrown. If I come back in and finish the comparison operator (which I needed to know was broken) it fixes the conditional statement at this point.Appreciated. John Jay Blanchard wrote:
[snip] if( ($mydata->address != "") and ($mydata->addresspublic == "yes") ) { } But in other combinations, they work? if($mydata->address != ""){} or if($mydata->addresspublic == "yes"){} So what new lesson am I to learn now? :) [/snip] Always put the value first in case you accidentally try an assignment operator. Now, on to your code...(with my recommendations) if(("" != $mydata->address) && ("yes" == $mydata->addresspublic)){ ...stuff... } if(("" != $mydata->address) || ("yes" == $mydata->addresspublic)){ ...stuff... } Those should work. Now, why do I recommend the value first? Easy. Consider... if($mydata->foo = "") // always true, $mydata->foo is now equal to blank If I do this... if("" = $mydata->foo) // an error is thrown. If I come back in and finish the comparison operator (which I needed to know was broken) it fixes the conditional statement at this point.-- John Taylor-Johnston ----------------------------------------------------------------------------- "If it's not Open Source, it's Murphy's Law." ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - 819-569-2064