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

Popular posts from this blog

GROUP BY Clause and HAVING Clause in PHP

Method Overriding in Traits in PHP

Mysqli database Connection and Display Table Data from Database