I just wanted to add that the following

$name = $_POST['name'] ?: 'Default Name';

with existence check would be

$name = $_POST['name'] ?? null ?: 'Default Name';

You don't need empty().

I would be against changing the behaviour of elvis/ternary operator.
However, I remember seeing past suggestions to implement another operator.
One that would fill the gap between null-coalesce and elvis operators. If I
recall correctly, most of the time, these proposals end in consensus that
such operator isn't really needed. See
https://externals.io/message/89292#89292 and
https://externals.io/message/101606#101610
Maybe, it would be worthwhile to refresh a discussion about adding such
operator to the PHP language?

Reply via email to