I would noramlly try to use the isset operator as below, where $x has to be forcefully set to null or $y if present
$x = isset($y) ? $y : null;
However below code does something similar. But, I am forced to write 'dummy' code in the below solution. How can I prevent this?
isset($y) ? $x = $y: 'dummy';
Which solution #1 or #2 would be preferred?
The principle which says that the "code is for programmers to read - and the binary is for the machine to read" applies here.
$x = isset($y) ? $y : null;
is clean and straightforward
while
isset($y) ? $x = $y: 'dummy';
is convoluted and oblique.