xref: /PHP-5.5/ext/simplexml/tests/012.phpt (revision 610c7fbe)
1--TEST--
2SimpleXML: Attribute creation
3--SKIPIF--
4<?php
5	if (!extension_loaded('simplexml')) print 'skip';
6?>
7--FILE--
8<?php
9
10$xml =<<<EOF
11<?xml version="1.0" encoding="ISO-8859-1" ?>
12<foo/>
13EOF;
14
15$sxe = simplexml_load_string($xml);
16
17
18$sxe[""] = "warning";
19$sxe["attr"] = "value";
20
21echo $sxe->asXML();
22
23$sxe["attr"] = "new value";
24
25echo $sxe->asXML();
26
27$sxe[] = "error";
28
29__HALT_COMPILER();
30?>
31===DONE===
32--EXPECTF--
33
34Warning: main(): Cannot write or create unnamed attribute in %s012.php on line %d
35<?xml version="1.0" encoding="ISO-8859-1"?>
36<foo attr="value"/>
37<?xml version="1.0" encoding="ISO-8859-1"?>
38<foo attr="new value"/>
39
40Fatal error: main(): Cannot create unnamed attribute in %s012.php on line %d
41