Re: syntax for multiple boolean

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You could write what your code does now like this.

if (empty ($fname) || empty ($sname) || empty ($address))
{
// do something
}

If you want your first condition to be met and one of your second two
conditions to be met you can do it like this:

if (empty ($fname) && (empty ($sname) || empty ($address)))
{
// do something
}

Of course the first example will run the code if any of the fields are
empty. The second will run it if the first and second or third are empty.
Hope that helps.

Andrew Darrow
Kronos1 Productions
www.pudlz.com

----- Original Message ----- 
From: "Ross" <ross@xxxxxxxxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
Sent: Saturday, August 27, 2005 10:42 AM
Subject:  syntax for multiple boolean


> I want to check if multiple fields are empty and want to find the best
> shorthand way to do it. What are the rules with brackets in PHP.
>
>
> if (empty ($fname){
>
> //do something
>
> }
>
> if (empty ($sname){
>
> //the same thing
>
> }
>
> if (empty ($address){
>
> //do the same ting again
>
> }
>
>
> R.
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.344 / Virus Database: 267.10.16/83 - Release Date: 8/26/2005
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux