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

Ajax Insert Records in Database Tutorial in PHP

Displaying Database data using Class, Object, Constructor, Destructor in PHP MySql

SubQuery with EXISTS and NOT EXISTS in PHP