Skip to content

Coding Hint

Solution of Technical Problems.

  • PHP
  • Facebook
  • Javascript
  • jQuery
  • Twitter
  • Smarty
PHP-Development

Ternary Operators

October 30, 2013 Chandan Sharma PHP Comments

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';
    }

Share and Enjoy

  • Facebook
  • Twitter
  • Google Plus
  • Live
  • Delicious
  • Digg
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
  • Instapaper
  • FriendFeed
Ternary Operators

Post navigation

« selecting data from mysql db using regular expression
Output buffering in php »
Facebook Flash htaccess Javascript jQuery Linux MYSQL PHP Smarty Twitter
Powered by WordPress and Tortuga.