Assign if not null - Otherwise leave original value

23 Views Asked by At

I'm using this line below, which works fine. My question is more for sport and curiosity than for practicality.

$x = $y ?? $x;

(How) could I get this even shorter in PHP? Having the $x in this line twice seems redundant.

0

There are 0 best solutions below