It seems like a lot of people don't know about these two gems. The first is inline if. vB for some reason has it's own iif function which works like:
PHP Code:
$a = 1;
echo iif(($a == 1), "a is one", "a is not one"); // echoes "a is one"
But you can just do this:
PHP Code:
$a = 1;
echo ($a == 1 ? "a is one" : "a is not one");
Also as a language construct it should be significantly faster than any user-defined function.
The other one is unnecessary ifs. Check this out:
PHP Code:
function stuff($s)
{
if ($s == 50)
{
return true;
}
else
{
return false;
}
}
You can just do this:
PHP Code:
function stuff($s)
{
return ($s == 50);
}
Just sharing the goodness. I don't know why so few people know about these.