#33906 [Opn->Bgs]: value comparsion doesn't work as expected

From: Date: Thu, 28 Jul 2005 14:23:16 +0000
Subject: #33906 [Opn->Bgs]: value comparsion doesn't work as expected
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-82596@lists.php.net to get a copy of this message
ID: 33906 Updated by: sniper@php.net Reported By: ray-chords at gmx dot net -Status: Open +Status: Bogus Bug Type: SimpleXML related Operating System: Debian Sarge PHP Version: 5.0.4 New Comment: RTFM. You have to cast to string first. Previous Comments: ------------------------------------------------------------------------ [2005-07-28 16:07:03] ray-chords at gmx dot net Description: ------------ Intention was to compare a string value with an xml node value. But direct access to the value fails. Reproduce code: --------------- <?php $xml_string = <<<EOD <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?> <document> <command default="yes"><id><![CDATA[li]]></id></command> <command><id><![CDATA[reg]]></id></command> <command><id><![CDATA[cq]]></id></command> <command><id><![CDATA[tipp]]></id></command> <command><id><![CDATA[pwd]]></id></command> </document> EOD; $xml = simplexml_load_string($xml_string); $template = $xml->xpath('/document/command/id'); foreach ($template as $v) { $out = ($v->id == 'pwd') ? 'OK' : 'FALSE'; print $out . "\n"; } ?> Expected result: ---------------- I'd expected an 'OK' in the last loop. But I always get 'FALSE'. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33906&edit=1

« previous php.bugs (#82596) next »