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-- xml_error_string() - Basic test on 5 error codes --EXTENSIONS-- xml --FILE-- <?ph..

Decoded Output download

--TEST--
xml_error_string() - Basic test on 5 error codes
--EXTENSIONS--
xml
--FILE--
<?php
$xmls = array(
    '<?xml version="1.0"?><element>',
    '<?xml>',
    '<?xml version="dummy">',
    '<?xml?>',
    '<?xml version="1.0"?><elem></element>',
);

foreach ($xmls as $xml) {
    $xml_parser = xml_parser_create();
    if (!xml_parse($xml_parser, $xml, true)) {
        var_dump(xml_get_error_code($xml_parser));
        var_dump(xml_error_string(xml_get_error_code($xml_parser)));
    }
    xml_parser_free($xml_parser);
}
?>
--EXPECT--
int(5)
string(20) "Invalid document end"
int(47)
string(35) "Processing Instruction not finished"
int(57)
string(28) "XML declaration not finished"
int(64)
string(17) "Reserved XML Name"
int(76)
string(14) "Mismatched tag"

Did this file decode correctly?

Original Code

--TEST--
xml_error_string() - Basic test on 5 error codes
--EXTENSIONS--
xml
--FILE--
<?php
$xmls = array(
    '<?xml version="1.0"?><element>',
    '<?xml>',
    '<?xml version="dummy">',
    '<?xml?>',
    '<?xml version="1.0"?><elem></element>',
);

foreach ($xmls as $xml) {
    $xml_parser = xml_parser_create();
    if (!xml_parse($xml_parser, $xml, true)) {
        var_dump(xml_get_error_code($xml_parser));
        var_dump(xml_error_string(xml_get_error_code($xml_parser)));
    }
    xml_parser_free($xml_parser);
}
?>
--EXPECT--
int(5)
string(20) "Invalid document end"
int(47)
string(35) "Processing Instruction not finished"
int(57)
string(28) "XML declaration not finished"
int(64)
string(17) "Reserved XML Name"
int(76)
string(14) "Mismatched tag"

Function Calls

xml_parser_create 1

Variables

$xml <?xml version="1.0"?><element>
$xmls [{'key': 0, 'value': '<?xml version="1.0"?><element>'}, {'key': 1, 'value': '<?xml>'}, {'key': 2, 'value': '<?xml version="dummy">'}, {'key': 3, 'value': '<?xml?>'}, {'key': 4, 'value': '<?xml version="1.0"?><elem></element>'}]

Stats

MD5 d71fa93f86ee1e9c4bbd9cb5c506853e
Eval Count 0
Decode Time 83 ms