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: invoking key() after the iterator has already been consumed --EXTENSIO..

Decoded Output download

--TEST--
SimpleXML: invoking key() after the iterator has already been consumed
--EXTENSIONS--
simplexml
--FILE--
<?php

$xml =<<<EOF
<?xml version='1.0'?>
<root>
<elem/>
</root>
EOF;

$sxe = simplexml_load_string($xml);

try {
    $sxe->key();
} catch (Error $exception) {
    echo $exception->getMessage() . "
";
}

for ($sxe->rewind(); $sxe->valid(); $sxe->next()) {
    var_dump($sxe->key(), $sxe->current());
}

try {
    $sxe->key();
} catch (Error $exception) {
    echo $exception->getMessage() . "
";
}

?>
--EXPECT--
Iterator not initialized or already consumed
string(4) "elem"
object(SimpleXMLElement)#3 (0) {
}
Iterator not initialized or already consumed

Did this file decode correctly?

Original Code

--TEST--
SimpleXML: invoking key() after the iterator has already been consumed
--EXTENSIONS--
simplexml
--FILE--
<?php

$xml =<<<EOF
<?xml version='1.0'?>
<root>
<elem/>
</root>
EOF;

$sxe = simplexml_load_string($xml);

try {
    $sxe->key();
} catch (Error $exception) {
    echo $exception->getMessage() . "\n";
}

for ($sxe->rewind(); $sxe->valid(); $sxe->next()) {
    var_dump($sxe->key(), $sxe->current());
}

try {
    $sxe->key();
} catch (Error $exception) {
    echo $exception->getMessage() . "\n";
}

?>
--EXPECT--
Iterator not initialized or already consumed
string(4) "elem"
object(SimpleXMLElement)#3 (0) {
}
Iterator not initialized or already consumed

Function Calls

simplexml_load_string 1

Variables

$xml <?xml version='1.0'?> <root> <elem/> </root>

Stats

MD5 9bd4e61dbcea14e63f6ec8f6deb1a422
Eval Count 0
Decode Time 80 ms