PHP boolean values - shorter and semantic IFs
This is a simple one but I am all for making code neater, tidier and more readable.
If you are using a boolean value for evaluating an IF statement, you would typically:
$valid = true;
if ($valid == true)
{
# do something
}
else
{
# do something else
}
A shorter and more readable (try saying it out loud in pseudo code) method would be:
if ($valid)And to test for false:
{
# do something
}
if (!$valid)A basic one, but I find the little touches make a big difference.
{
# do something
}
