473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.
Jul 17 '05 #1
4 1602
"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
Jul 17 '05 #2
On Tue, 10 Aug 2004 23:28:15 -0400, steve wrote:
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)

A variable assigned an empty string is _not_ the same as it being NULL.
if (!is_null($value1) and strlen($value1) < 1) {

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #3
On Wed, 11 Aug 2004 04:38:32 +0000, Ian.H wrote:
On Tue, 10 Aug 2004 23:28:15 -0400, steve wrote:
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)

A variable assigned an empty string is _not_ the same as it being NULL.
if (!is_null($value1) and strlen($value1) < 1) {

Oops:
if (!is_null($value1) and strlen($value1) > 0) {
Better =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #4
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?
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: delisonews | last post by:
I'm looking for a simple, filesystem-based message board. (No MySQL!) Something that I could include easily in my code: include '../inc/messageboard.php'; .... so that the board shows up at...
8
by: Dan | last post by:
Using XML::Simple in perl is extreemly slow to parse big XML files (can be up to 250M, taking ~1h). How can I increase my performance / reduce my memory usage? Is SAX the way forward?
6
by: Manuel Collado | last post by:
I would like to write simple, yet well structured documents with a really simple XML DTD (or schema). Either Docbook or SDocbook are overkill for this simple case. XHTML is simpler, but...
11
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
13
by: Michael B Allen | last post by:
Hi, I've tried to write the *simplest* memory allocator possible. I think it would be useful in many cases such as allocating memory on stack as a poor man's garbage collection perhaps. I was...
4
by: Rodrigo Ferreira | last post by:
Anyone uses the simple button component from DevExpress?
19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
24
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
14
by: Giancarlo Berenz | last post by:
Hi: Recently i write this code: class Simple { private: int value; public: int GiveMeARandom(void);
6
kenobewan
by: kenobewan | last post by:
Congratulations! You are one of the few who realise that over 80% of errors are simple and easy to fix. It is important to realise this as it can save a lot of time. Time that could be wasted making...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.