473,809 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1621
"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($valu e1) 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($valu e1) and strlen($value1) < 1) {

Oops:
if (!is_null($valu e1) 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
6082
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 the bottom of every PHP page. The board should have just the basic features, like: - posting capability
8
6507
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
2071
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 unstructured (no nested sections). And is not really very simple. Before trying to setup a stripped-down document format by myself, I would like to know if there are simple XML document structure proposals ready to be used (I dislike to reinvent the...
11
2721
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
5746
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 hoping the clc crowd had some ideas for making it even simpler! In-lined below the full program (132 lines). It's a circular singular linked list of "cells" inspired by the one in Plauger's text
4
1908
by: Rodrigo Ferreira | last post by:
Anyone uses the simple button component from DevExpress?
19
2992
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 provide an open TD with a DIV in it for the content of this formlet. (The DIV is for DHTML to hide and show the content) I've created a web page showing step by step the two problems I'm encountering. This problem is much easier to see than it...
24
6348
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 have on his site, a Javascript Calculator for working out the cost of what they want, for example: 1 widget and 2 widglets = £5.00
14
2990
by: Giancarlo Berenz | last post by:
Hi: Recently i write this code: class Simple { private: int value; public: int GiveMeARandom(void);
6
28874
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 unnecessary changes, that in turn can cause further problems. Programming is a humbling experience. An experience that causes one to reflect on human error. One major cause of these errors is syntax, syntax, syntax. We tend not to notice when we...
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9602
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10639
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7661
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.