This is perhaps the main question that needs to be answered, but I am wondering about performance issues regarding the use of PHP if it is identical !==against if equal !=for flow control.
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.';
}
}
?>
In terms of performance, is it preferable to use if identical ( !==) to prevent iteration of PHP through variable types, trying to find the right comparison?
I assume it !==compares the types of variables first, and if that fails, does it immediately return FALSE? I used !=since PHP3 is almost like a reflex. Now that I am working on much more complex computing projects, considerations of minimal performance are becoming increasingly serious problems.
Other comments on streamlining optimization are of course welcome!
source
share