Giving Zend exam soon and i came across IF-ELSE in the control structures heading.
I know about if and else and even elseif but what the hell is IF-ELSE?
The guide book says its a ternary operator
What is IF-ELSE ?
Moderator: General Moderators
Re: What is IF-ELSE ?
The ternary operator in PHP is ?, which is a sort of shorthand for if/else
Are equivalent statements
Code: Select all
if ($x == 1) {
$y = 1;
} else {
$y = 2;
}Code: Select all
$y = ($x == 1) ? 1 : 2;