This is perhaps a painfully basic question to answer, but I'm wondering about performance issues regarding using PHP's if identical !==
versus if equal !=
to control flow.
Consider the following trivial PHP function:
<?php
function test_json($json = NULL) {
if ($json != NULL) {
echo 'You passed some JSON.';
} else {
echo 'You failed to pass any JSON.';
}
}
?>
From a performance standpoint, is it preferable to employ if identical (!==
) to prevent PHP iterating through variable types, attempting to find a valid comparison?
I assume that !==
first compares the variable types, and if that fails, it immediately returns FALSE
?
I've used !=
since PHP3 almost as a reflex. Now that I'm working on some much more computationally-intensive projects, minute performance considerations become more of a concern.
Other comments on flow control optimization are, of course, welcome!