Since PHP treats them equally in string operations and output, I would like to know what is the best practice, to assign/concatenate a null value or an empty string:
$lang = 'lang';
$suffix = null;
$lang .= $suffix;
or
$desc = 'name';
$suffix = '';
$desc .= $suffix;
This can also be the case for inline conditions:
<div class="item<?= $is_selected ? ' selected' : null ?>"></div>
or
<div class="item<?= $is_selected ? ' selected' : '' ?>"></div>
I know it won’t affect the overall performance, but could it compare to using double or single quotes?
Ran this a few times, and got very similar results every time.
Conclusion:
nullto an empty string.