xref: /PHP-8.3/ext/simplexml/tests/bug72957.phpt (revision 7f2f0c00)
1--TEST--
2Bug #72957: Null coalescing operator doesn't behave as expected with SimpleXMLElement
3--EXTENSIONS--
4simplexml
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