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


Popular posts from this blog

Get URL Parameters Using Javascript

PHP 5.4 beta1 released