Re: syntax for multiple boolean

From: Date: Sat, 27 Aug 2005 19:12:50 +0000
Subject: Re: syntax for multiple boolean
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-221472@lists.php.net to get a copy of this message
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@aztechost.com> To: <php-general@lists.php.net> Sent: Saturday, August 27, 2005 10:42 AM Subject: [PHP] 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 > >

« previous php.general (#221472) next »