Ternary Operators

This operator takes three arguments – a condition, a result for true, and a result for false.

It is a shortcut of doing if statements. Here’s an example:



    $result = ($a < 16) ? 'true' : 'false';


    if ($a < 16) {
        $result = 'true';
    } else {
        $result = 'false';
    }






Use Facebook to Comment on this Post


Comments

Popular posts from this blog

cookie and subdomains

How to check browser cookie enabled with php and javascript