For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > March 2006 > #36841 [Opn->Bgs]: Empty objects are false?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #36841 [Opn->Bgs]: Empty objects are false?
simp@php.net

2006-03-29, 9:57 pm

ID: 36841
Updated by: simp@php.net
Reported By: clemens at gutweiler dot net
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
Operating System: Linux
PHP Version: 5.1.2
New Comment:

Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same.

Thank you for your interest in PHP.

http://bugs.php.net/bug.php?id=30972

This behaviour of the SimpleXML cast handler is now documented. Thanks
for your input.


Previous Comments:
------------------------------------------------------------------------

[2006-03-24 10:31:38] clemens at gutweiler dot net

Is this behaviour of SimpleXML documentated?
I could only find, that objects are false in PHP4 only. And in PHP5
objects should cast to true in any case or?

http://www.php.net/manual/en/langua...boolean.casting

------------------------------------------------------------------------

[2006-03-24 10:03:38] tony2001@php.net

This is expected behaviour of SimpleXML (and it has nothing to do with
the engine).
No bug here.

------------------------------------------------------------------------

[2006-03-24 10:00:12] clemens at gutweiler dot net

Description:
------------
casting empty simplexml objects to boolean, empty objects get
transformed to false.

Reproduce code:
---------------
var_dump( $foo = simplexml_load_string( "<foo />" ) );
object(SimpleXMLElement)#1 (0) {
}

var_dump( (bool)simplexml_load_string( "<foo />" ) );
bool(false)

var_dump( (bool)simplexml_load_string( "<foo>foo</foo>" ) );
bool(true)

Expected result:
----------------
both boolean-casts should be true.



------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=36841&edit=1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com