xref: /PHP-8.4/ext/simplexml/tests/bug39760.phpt (revision 7f2f0c00)
1--TEST--
2Bug #39760 (cloning fails on nested SimpleXML-Object)
3--EXTENSIONS--
4simplexml
5--FILE--
6<?php
7
8$xml = '<?xml version="1.0" ?>
9<test>
10    <level1>
11        <level2a>text1</level2a>
12        <level2b>text2</level2b>
13   </level1>
14</test>';
15$test = simplexml_load_string($xml);
16
17var_dump($test->level1->level2a);
18
19$test2 = clone $test;
20var_dump($test2->level1->level2a);
21
22$test3 = clone $test->level1->level2a;
23var_dump($test3);
24
25echo "Done\n";
26?>
27--EXPECTF--
28object(SimpleXMLElement)#%d (1) {
29  [0]=>
30  string(5) "text1"
31}
32object(SimpleXMLElement)#%d (1) {
33  [0]=>
34  string(5) "text1"
35}
36object(SimpleXMLElement)#%d (1) {
37  [0]=>
38  string(5) "text1"
39}
40Done
41