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

PHP 5.4 beta1 released

How to check browser cookie enabled with php and javascript

how to check whether element is visible on screen