#35028 [Opn->Asn]: XML object fails FALSE test

From: Date: Sun, 30 Oct 2005 20:45:43 +0000
Subject: #35028 [Opn->Asn]: XML object fails FALSE test
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-87234@lists.php.net to get a copy of this message
ID: 35028 Updated by: helly@php.net Reported By: lists at cyberlot dot net -Status: Open +Status: Assigned Bug Type: SimpleXML related -Operating System: Fedore Core 3 +Operating System: * -PHP Version: 5.1.0RC4 +PHP Version: 5.1.0 -Assigned To: +Assigned To: helly New Comment: For 5.1.0 you'd need to use isset() instead of plain if() test since we are too far in release process to have a big changes in it. But i will do just after 5.1.0 is out the doors. Also it is fixed in HEAD. Anyway i tried it with 5.0.6-dev and am nearly sure it does not work in any version yet. Btw, a boolean if() for normal php objects is a check whether the object has any properties. This is probably not what you want. After the change it results in true whenever there are sub elements, attributes or a selected node. Previous Comments: ------------------------------------------------------------------------ [2005-10-30 19:29:44] alex at whitewhale dot net Note that if you change $string to: $string = str_replace('><','> <',"<doc><login>kkl</ login><password>klk</password></doc>"); It passes. ------------------------------------------------------------------------ [2005-10-30 19:21:46] lists at cyberlot dot net Description: ------------ $xml object returns false, this worked in RC1 fails in RC3 and RC4 never tested RC2 xml string of <doc>test</doc> DOES pass test. Its only when you have subchildren children that the $xml object fails to pass. <doc><test>test</test></doc> fails <doc>test</doc> Passes. if(is_object($xml)) { works, and is prob the best method to use but one would expect $xml to be "true" Realize this might be considered a dupe of bug #31045 however bug #34199 suggests the same issue that states this is fixed. Reproduce code: --------------- <? $string = "<doc><login>kkl</login><password>klk</password></doc>"; $xml = simplexml_load_String($string); if($xml) { echo "Passed test\n"; } else { echo "Even though is object still failed false test\n"; } ?> Expected result: ---------------- Expect output of Passed test Actual result: -------------- output of Even though is object still failed false test ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35028&edit=1

« previous php.bugs (#87234) next »