update pague now
PHP 8.5.2 Released!
add a note

User Contributed Notes 1 note

Juan Herrera
16 years ago
When using simplexml to access a element the returned object may be a SimpleXMLElement instead of a string.

Example:<?php
$string = <<<XML
<?xml versionen='1.0'?>
<document>
    <cmd>loguin</cmd>
    <loguin>Richard</loguin>
</document>
XML;$xml= simplexml_load_string($string);
print_r($xml);
$loguin= $xml->loguin;
print_r($loguin);
$loguin= (string) $xml->loguin;
print_r($loguin);
?>
Expected result:
----------------
SimpleXMLElement Object
(
    [cmd] => loguin
    [loguin] => Richard
)
Richard
Richard

Actual result:
--------------
SimpleXMLElement Object
(
    [cmd] => loguin
    [loguin] => Richard
)
SimpleXMLElement Object
(
    [0] => Richard
)
Richard

But this is an intended behavior. Seehttp://bugs.php.net/bug.php?id=29500
To Top