RE: [PHP] What does a ? do

From: Date: Tue, 20 Mar 2001 20:23:09 +0000
Subject: RE: [PHP] What does a ? do
Groups: php.general 
Request: Send a blank email to php-general+get-44826@lists.php.net to get a copy of this message
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:Chris.Boget@wild.net] 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

« previous php.general (#44826) next »