This question might be "a bit out there". But more or less it's microbenching code, but it's to improve my standards and general knowledge of PHP's backend.
SO! Here I go, my question! Would calling a variable twice require less memory (and load on CPU) than calling an additional else condition in PHP? Which requires more resources? And why?
The Below examples:
A, shows calling a variable twice and B, shows calling an additional else condition. Both have the same end result, of course.
Any additional references to any answers (responds) would be highly appropriated too! If possible.
Example A:
$a = 1;
if (isset($array['a']))
{
$a = $array['a'];
}
$b = NULL;
if (isset($array['b']))
{
$b = $array['b'];
}
Example B:
if (isset($array['a']))
{
$a = $array['a'];
}
else
{
$a = 1;
}
if (isset($array['b']))
{
$b = $array['b'];
}
else
{
$b = NULL;
}