devWhiz Posted January 27, 2012 Share Posted January 27, 2012 I see a couple people using the ? operator in php and was curious as to how it works? Link to comment https://forums.phpfreaks.com/topic/255858-how-does-the-operator-work-in-php/ Share on other sites More sharing options...
AyKay47 Posted January 27, 2012 Share Posted January 27, 2012 its called the "ternary" operator. http://php.net/manual/en/language.operators.comparison.php Link to comment https://forums.phpfreaks.com/topic/255858-how-does-the-operator-work-in-php/#findComment-1311567 Share on other sites More sharing options...
Pikachu2000 Posted January 27, 2012 Share Posted January 27, 2012 It's only part of a ternary statement in the following context. It needs to have the colon with it to be used in ternary syntax. $variable = $num == 5 ? 'is five' : 'is not five'; Link to comment https://forums.phpfreaks.com/topic/255858-how-does-the-operator-work-in-php/#findComment-1311569 Share on other sites More sharing options...
AyKay47 Posted January 27, 2012 Share Posted January 27, 2012 well noted, to avoid confusion i will state that the ? is only part of the ternary operator, as pika corrected me on, the link I provided has the documentation on the subject. Link to comment https://forums.phpfreaks.com/topic/255858-how-does-the-operator-work-in-php/#findComment-1311573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.