xref: /PHP-8.0/ext/simplexml/tests/bug72957.phpt (revision 345b96c4)
1--TEST--
2Bug #72957: Null coalescing operator doesn't behave as expected with SimpleXMLElement
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip simplexml extension is not loaded"; ?>
5--FILE--
6<?php
7
8$xml = new SimpleXMLElement('<root><elem>Text</elem></root>');
9
10echo 'elem2 is: ' . ($xml->elem2 ?? 'backup string') . "\n";
11echo 'elem2 is: ' . (isset($xml->elem2) ? $xml->elem2 : 'backup string') . "\n";
12
13?>
14--EXPECT--
15elem2 is: backup string
16elem2 is: backup string
17