There are certain things that still do not come into my head in relation to PHP.
Because there is the is_null
function, when we can simply compare the values through a comparison operator. Such as $variable === NULL
?
And why in some tutorials recommend the "flipping" of this check.
That is, instead of using
if ($variable === NULL) {
// faça alguma coisa
}
Teach you how to use:
if (NULL === $variable) {
// faça alguma coisa
}
But in some frameworks , such as Laravel, I see a lot:
if ( is_null($variable)) {
// faça alguma coisa
}
They say it's faster to do as in the second example.
But is this really something I should worry about? Or is it just a ridiculous micro-optimization?
Should I stop putting is_null
in my codes, since a comparison operator consumes less resource in memory than a function call?
Is there a standard (some FIG Standard) that helps with this task, to facilitate standardization?