Re: $i % 2 ? 0:

From: Date: Sat, 25 Aug 2001 17:16:56 +0000
Subject: Re: $i % 2 ? 0:
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-64446@lists.php.net to get a copy of this message
"Mike Cullerton" <php-l@bakednotfried.com> wrote in message news:B7AD32BC.12C46%php-l@bakednotfried.com... > it's an if/else shortcut. > > the part before the '?' is tested. '$i % 2' in your case. > > the part after the '?' is returned if the test evals to true. '0' in your > case. Documentation at http://www.php.net/manual/en/language.operators.comparison.php Think of ( A ? B : C ) as if (A) return B; else return C; For example, $a = 2; echo "The value of a is" . ($a == 2 ? "" : " not" ) . " 2";

« previous php.general (#64446) next »