xref: /PHP-8.0/ext/simplexml/tests/bug35785.phpt (revision df79277d)
1--TEST--
2Bug #35785 (SimpleXML memory read error)
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
5--FILE--
6<?php
7
8$xml = simplexml_load_string("<root></root>");
9$xml->bla->posts->name = "FooBar";
10echo $xml->asXML();
11$xml = simplexml_load_string("<root></root>");
12var_dump(isset($xml->bla->posts));
13$xml->bla->posts[0]->name = "FooBar";
14echo $xml->asXML();
15$xml = simplexml_load_string("<root></root>");
16$xml->bla->posts[]->name = "FooBar";
17echo $xml->asXML();
18?>
19--EXPECT--
20<?xml version="1.0"?>
21<root><bla><posts><name>FooBar</name></posts></bla></root>
22bool(false)
23<?xml version="1.0"?>
24<root><bla><posts><name>FooBar</name></posts></bla></root>
25<?xml version="1.0"?>
26<root><bla><posts><name>FooBar</name></posts></bla></root>
27