Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
--TEST-- SimpleXML: adding/removing attributes (direct) --EXTENSIONS-- simplexml --FILE-- ..
Decoded Output download
--TEST--
SimpleXML: adding/removing attributes (direct)
--EXTENSIONS--
simplexml
--FILE--
<?php
$xml =<<<EOF
<people>
<person name="Joe"></person>
</people>
EOF;
$people = simplexml_load_string($xml);
var_dump($people->person['name']);
var_dump($people->person['age']);
$person = $people->person;
$person['name'] = "XXX";
var_dump($people->person['name']);
$people->person['age'] = 30;
var_dump($people->person['age']);
echo "---Unset:---
";
unset($people->person['age']);
echo "---Unset?---
";
var_dump($people->person['age']);
var_dump(isset($people->person['age']));
$people->person['age'] = 30;
echo "---Unsupported---
";
var_dump($people->person['age']);
$people->person['age'] += 5;
var_dump($people->person['age']);
?>
--EXPECTF--
object(SimpleXMLElement)#%d (1) {
[0]=>
string(3) "Joe"
}
NULL
object(SimpleXMLElement)#%d (1) {
[0]=>
string(3) "XXX"
}
object(SimpleXMLElement)#%d (1) {
[0]=>
string(2) "30"
}
---Unset:---
---Unset?---
NULL
bool(false)
---Unsupported---
object(SimpleXMLElement)#%d (1) {
[0]=>
string(2) "30"
}
object(SimpleXMLElement)#%d (1) {
[0]=>
string(2) "35"
}
Did this file decode correctly?
Original Code
--TEST--
SimpleXML: adding/removing attributes (direct)
--EXTENSIONS--
simplexml
--FILE--
<?php
$xml =<<<EOF
<people>
<person name="Joe"></person>
</people>
EOF;
$people = simplexml_load_string($xml);
var_dump($people->person['name']);
var_dump($people->person['age']);
$person = $people->person;
$person['name'] = "XXX";
var_dump($people->person['name']);
$people->person['age'] = 30;
var_dump($people->person['age']);
echo "---Unset:---\n";
unset($people->person['age']);
echo "---Unset?---\n";
var_dump($people->person['age']);
var_dump(isset($people->person['age']));
$people->person['age'] = 30;
echo "---Unsupported---\n";
var_dump($people->person['age']);
$people->person['age'] += 5;
var_dump($people->person['age']);
?>
--EXPECTF--
object(SimpleXMLElement)#%d (1) {
[0]=>
string(3) "Joe"
}
NULL
object(SimpleXMLElement)#%d (1) {
[0]=>
string(3) "XXX"
}
object(SimpleXMLElement)#%d (1) {
[0]=>
string(2) "30"
}
---Unset:---
---Unset?---
NULL
bool(false)
---Unsupported---
object(SimpleXMLElement)#%d (1) {
[0]=>
string(2) "30"
}
object(SimpleXMLElement)#%d (1) {
[0]=>
string(2) "35"
}
Function Calls
simplexml_load_string | 1 |
Stats
MD5 | c48e7668660dc6d96a111565c6c4129b |
Eval Count | 0 |
Decode Time | 107 ms |