RE: if(($mydata->address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[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.

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux