a simple if-login question

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


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-11-2004
steve
 
Posts: n/a
Default Re: a simple if-login question

"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
Reply With Quote
  #2 (permalink)  
Old 08-11-2004
Maxim Vexler
 
Posts: n/a
Default a simple if-login question

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.
Reply With Quote
  #3 (permalink)  
Old 08-11-2004
Maxim Vexler
 
Posts: n/a
Default Re: a simple if-login question

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?
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:11 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0