0

it seems a bit odd how the ternary operator works in php, can someone shed light?

$z = 'testval';
$x = 'hello ' . isset($z) ? $z : ' notfound';

var_dump($x);  //testval

this results in the expected result:

$z = 'testval';
$x = 'hello ' . (isset($z) ? $z : ' notfound');

var_dump($x); //returns hello testval
Toskan
  • 13,911
  • 14
  • 95
  • 185

0 Answers0