RE: [PHP] If Else Syntax Incorrect (I Think)

From: Date: Fri, 13 Aug 2004 14:06:00 +0000
Subject: RE: [PHP] If Else Syntax Incorrect (I Think)
Groups: php.general 
Request: Send a blank email to php-general+get-193698@lists.php.net to get a copy of this message
On 13 August 2004 12:52, Jay Blanchard wrote: > if( strlen( $UserID ) != 0 > && strlen( $UserPassword ) != 0 > && strlen( $SecretPassword ) != 0 > && strlen( $UserMail ) != 0 ) > { > Do something > } > elseif ( strlen( $UserID ) == 0 > > > strlen( $UserPassword ) == 0 > > > strlen( $SecretPassword ) == 0 > > > strlen( $UserMail ) == 0 ) > { > Do Something else > } In fact since the elseif condition is the exact logical complement of the if condition (by application of deMorgan's rules), you only need: if( strlen( $UserID ) != 0 && strlen( $UserPassword ) != 0 && strlen( $SecretPassword ) != 0 && strlen( $UserMail ) != 0 ) { Do something } else { Do Something else } Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#193698) next »