Ternary_Operator
<?php
$x = 10;
//First Way to represent
($x > 20) ? $z = "Greater" : $z = "Smaller";
//Second Way to represent
$z = $x > 20 ? "Greater" : "Smaller";
//Third Way to represent
$z = "Value is : " . ($x > 20 ? "Greater " : "Smaller");
echo $z;
//OUTPUT: Value is : Smaller
?>
Comments
Post a Comment