xref: /PHP-8.3/ext/simplexml/tests/bug72588.phpt (revision 7f2f0c00)
1--TEST--
2Bug #72588 (Using global var doesn't work while accessing SimpleXML element)
3--EXTENSIONS--
4simplexml
5--FILE--
6<?php
7
8$tpnb = 5;
9$dummy = &$tpnb;
10
11$xmlStruct = <<<EOF
12<?xml version="1.0" encoding="UTF-8"?>
13<templates>
14    <object type="obj_1" label="Label for object 1"></object>
15    <object type="obj_2" label="Label for object 2"></object>
16    <object type="obj_3" label="Label for object 3"></object>
17    <object type="obj_4" label="Label for object 4"></object>
18    <object type="obj_5" label="Label for object 5"></object>
19    <object type="obj_6" label="Label for object 6"></object>
20    <object type="obj_7" label="Label for object 7"></object>
21    <object type="obj_8" label="Label for object 8"></object>
22    <object type="obj_9" label="Label for object 9"></object>
23    <object type="obj_10" label="Label for object 10"></object>
24</templates>
25EOF;
26$tplxml = simplexml_load_string($xmlStruct);
27
28var_dump($tplxml->object[$tpnb]);
29?>
30--EXPECTF--
31object(SimpleXMLElement)#%d (1) {
32  ["@attributes"]=>
33  array(2) {
34    ["type"]=>
35    string(5) "obj_6"
36    ["label"]=>
37    string(18) "Label for object 6"
38  }
39}
40