This is a discussion on a simple if-login question within the PHP Language forums, part of the PHP Programming Forums category; "Maxim Vexler" wrote: > if ((($value1 != null) || ($value1 != "")) && $value2 != "" && $value1 &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
"Maxim Vexler" wrote:
> if ((($value1 != null) || ($value1 != "")) && $value2 != "" && $value1 > > != $value2) { ret false } > > if i omit the [value2 != ""] i would still get the same result, right? > > because I check if value1 != "" and then I check if value1!=value2 > i.e. : > > if ((($value1 != null) || ($value1 != "")) && $value1 != value2) { ret > > false } > > regards, maxim. I believe you are right. And you can simplify as well: ($value1 != null) || ($value1 != "")) is equal to: ($value1 != ’’) [[don’t need the two statements]] or if you have doubts, use: (strlen($value1) > 0) -- http://www.dbForumz.com/ This article was posted by author's request Articles individually checked for conformance to usenet standards Topic URL: http://www.dbForumz.com/PHP-simple-l...ict138481.html Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=462837 |
|
|||
|
if ((($value1 != null) || ($value1 != "")) && $value2 != "" && $value1
!= $value2) { ret false } if i omit the [value2 != ""] i would still get the same result, right? because I check if value1 != "" and then I check if value1!=value2 i.e. : if ((($value1 != null) || ($value1 != "")) && $value1 != value2) { ret false } regards, maxim. |
|
|||
|
steve wrote:
> "Maxim Vexler" wrote: > > if ((($value1 != null) || ($value1 != "")) && $value2 != "" && > $value1 > > > > != $value2) { ret false } > > > > if i omit the [value2 != ""] i would still get the same result, > right? > > > > because I check if value1 != "" and then I check if > value1!=value2 > > i.e. : > > > > if ((($value1 != null) || ($value1 != "")) && $value1 != value2) > { ret > > > > false } > > > > regards, maxim. > > I believe you are right. And you can simplify as well: > ($value1 != null) || ($value1 != "")) > is equal to: > ($value1 != ’’) [[don’t need the two statements]] > or if you have doubts, use: > (strlen($value1) > 0) > in fact, and please correct me if I'm wrong : the logic (($value1 != null) || ($value1 != "")) is totally useless ! because no matter what the input is you always get true from it, right? |