bug72957.phpt 405 B

12345678910111213141516
  1. --TEST--
  2. Bug #72957: Null coalescing operator doesn't behave as expected with SimpleXMLElement
  3. --EXTENSIONS--
  4. simplexml
  5. --FILE--
  6. <?php
  7. $xml = new SimpleXMLElement('<root><elem>Text</elem></root>');
  8. echo 'elem2 is: ' . ($xml->elem2 ?? 'backup string') . "\n";
  9. echo 'elem2 is: ' . (isset($xml->elem2) ? $xml->elem2 : 'backup string') . "\n";
  10. ?>
  11. --EXPECT--
  12. elem2 is: backup string
  13. elem2 is: backup string