Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #10522
| From | Norman Peelman <npeelman@cfl.rr.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: AND and OR |
| Date | 2013-08-16 06:48 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <kul02j$qos$1@dont-email.me> (permalink) |
| References | <kujr9n$il7$1@speranza.aioe.org> <kukun7$l54$4@news.albasani.net> |
On 08/16/2013 06:25 AM, The Natural Philosopher wrote:
> On 16/08/13 01:21, Twayne wrote:
>> Hi,
>>
>> Doing code cleanup; something that seemed so simple is giving me lots
>> of trouble for whatever reason.
>>
>> Win 7, XAMPP, PHP 5.3, online forms:
>>
>> In my cleanup efforts I've been trying to concatenate statements for
>> things like the following:
>>
>> IF(strlen(var1) == 0) OR strlen(var2) == 0) OR strlen(var3) ==0))
>> {
>> code; notify user of errors that must be corrected.
>> }
>>
>> I know OR is || and AND is &&, and have tried every combination of
>> code I can think of but I consistently get syntax errors and it never
>> works.
>> Doing each var independently works fine; e.g. if(strlen($var) == 0)
>> {...}, works as expected, first time every time.
>>
>
> your brackets are screwed.
>
> if ((strlen(var1) == 0) || (strlen(var2) == 0) || (strlen(var3) ==0))
>
> will work
> as will
> if (strlen(var1) == 0 || strlen(var2) == 0 || strlen(var3) ==0)
>
As well as:
if (!strlen(var1) || !strlen(var2) || !strlen(var3))
--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
AND and OR Twayne <nobody@spamcop.net> - 2013-08-15 20:21 -0400
Re: AND and OR Paul Herber <paul@pherber.com> - 2013-08-16 01:30 +0100
Re: AND and OR Christoph Michael Becker <cmbecker69@arcor.de> - 2013-08-16 13:08 +0200
Re: AND and OR Twayne <nobody@spamcop.net> - 2013-08-16 12:14 -0400
Re: AND and OR "Peter H. Coffin" <hellsop@ninehells.com> - 2013-08-15 20:08 -0500
Re: AND and OR Tim Streater <timstreater@greenbee.net> - 2013-08-16 08:52 +0100
Re: AND and OR Twayne <nobody@spamcop.net> - 2013-08-16 11:19 -0400
Re: AND and OR The Natural Philosopher <tnp@invalid.invalid> - 2013-08-16 11:25 +0100
Re: AND and OR Norman Peelman <npeelman@cfl.rr.com> - 2013-08-16 06:48 -0400
Re: AND and OR The Natural Philosopher <tnp@invalid.invalid> - 2013-08-16 12:24 +0100
Re: AND and OR Twayne <nobody@spamcop.net> - 2013-08-16 12:10 -0400
Re: AND and OR The Natural Philosopher <tnp@invalid.invalid> - 2013-08-16 17:35 +0100
Re: AND and OR Tim Streater <timstreater@greenbee.net> - 2013-08-16 17:47 +0100
Re: AND and OR The Natural Philosopher <tnp@invalid.invalid> - 2013-08-16 18:13 +0100
Re: AND and OR Richard Yates <richard@yatesguitar.com> - 2013-08-17 07:20 -0700
Re: AND and OR The Natural Philosopher <tnp@invalid.invalid> - 2013-08-17 15:36 +0100
Re: AND and OR Richard Yates <richard@yatesguitar.com> - 2013-08-17 10:47 -0700
Re: AND and OR Twayne <nobody@spamcop.net> - 2013-08-17 14:05 -0400
Re: AND and OR The Natural Philosopher <tnp@invalid.invalid> - 2013-08-17 19:40 +0100
Re: AND and OR Twayne <nobody@spamcop.net> - 2013-08-17 13:27 -0400
Re: AND and OR Twayne <nobody@spamcop.net> - 2013-08-17 13:22 -0400
Re: AND and OR Richard Yates <richard@yatesguitar.com> - 2013-08-17 07:19 -0700
Re: AND and OR Twayne <nobody@spamcop.net> - 2013-08-16 11:53 -0400
Re: AND and OR Twayne <nobody@spamcop.net> - 2013-08-16 11:42 -0400
csiph-web