I used this code to profile both approaches:
<?php
$iterations = 1000000;
$startTime = microtime( true );
$i = 0;
while( ++$i < $iterations ) {
if(!isset($myVar) || $myVar == 'val'){
$myVar = 'oldVal';
}
if(isset($myVar) && $myVar == 'oldVal'){
$myVar = 'newVal';
}
}
echo 'First Running Time: ' . (microtime(true) - $startTime) . "\n";
$startTime = microtime( true );
$i = 0;
while( ++$i < $iterations ) {
(!isset($myVar) || $myVar == 'val') && $myVar = 'oldVal';
isset($myVar) && $myVar == 'oldVal' && $myVar = 'newVal';
}
echo 'Second Running Time: ' . (microtime(true) - $startTime) . "\n";
The results:
(1st Run)
First Running Time: 0.38401508331299
Second Running Time: 0.40315389633179
(2nd Run)
First Running Time: 0.38593697547913
Second Running Time: 0.40187788009644
Conclusion: Your method is slower, but the amount is so small that even if it weren't you would still be better off writing more readable code.