shorthand if code example
Example 1: php shorthand if
$is_admin = ($user['permissions'] == 'admin') ? true : false;
Example 2: php if short form
<?php echo ($qte > 0) ? $qte : 0; ?>
Example 3: short for if
#include <iostream>
//Another variation:
a == 1 ? std::cout << "1" : (a == 2 ? std::cout << "2" : a = 3);
//This is the same as:
if(a == 1)
{
std::cout << "1";
}
else if (a == 2)
{
std::cout << "2";
}
else
{
a = 3;
}