It's called the 'ternary operator' (taking three arguments and stuff).. and
I believe it is the only ternary operator at least in PHP.
-----Original Message-----
From: Boget, Chris [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 20, 2001 3:11 PM
To: 'Brandon Orther'; PHP User Group
Subject: RE: [PHP] What does a ? do
> Could someone plese explain this line if code??? What does the "?" do?
> $r = ($r < 1) ? $config['maxResults'] : $r;
It's short circuit IF (I believe that's the right word for it). This is the
same
thing as doing this:
if( $r < 1 ) {
$r = $config['maxResults'];
} else {
$r = $r;
}
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]