Ask a Question related to PHP Development, Design and Development.
-
bart at mediawave dot nl #1
#26380 [Opn]: empty($SimpleXMLObject) doesn't return true when empty
ID: 26380
User updated by: bart at mediawave dot nl
-Summary: Find out whether an object is empty
Reported By: bart at mediawave dot nl
Status: Open
-Bug Type: Feature/Change Request
+Bug Type: Zend Engine 2 problem
Operating System: Windows 2000
PHP Version: 5.0.0b2 (beta2)
New Comment:
Changed this to "Zend Engine 2 problem" because it seems empty() should
return true if an object has no properties:
[url]http://www.php.net/manual/en/function.empty.php[/url]
Previous Comments:
------------------------------------------------------------------------
[2003-11-24 07:36:26] bart at mediawave dot nl
Description:
------------
This bug/feature request has some relation with bug: #25640.
I've loaded XML into a simpleXML object. SimpleXML currently loads
empty tags (e.g. <tag />) as empty SimpleXML objects.
With the SimpleXML object I wanted to use the following code to find
out whether a tag has child tags or not:
if (is_object($SimpleXMLObjectNode)) {
// $node has child tags
Unfortunately this doesn't work very well since this code will think
that empty tags have child tags too. (Since empty tags are loaded as
objects)
Therefore I thought it would be a nice feature to be able to find out
whether an object is empty or not. Something like:
if (empty($object)) {
// Object is empty
}
Reproduce code:
---------------
<?php
$xml = '<wrapper><foo></foo><bar>s2</bar><bar>s3</bar></wrapper>';
$t = simplexml_load_string($xml);
print_r($t);
if (empty($t->foo)) {
echo 'Tag is empty';
} else {
echo 'Tag has contents';
}
?>
Expected result:
----------------
Tag is empty
Actual result:
--------------
Tag has contents
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=26380&edit=1[/url]
bart at mediawave dot nl Guest
-
#26380 [NEW]: Find out whether an object is empty
From: bart at mediawave dot nl Operating system: Windows 2000 PHP version: 5.0.0b2 (beta2) PHP Bug Type: Feature/Change... -
#25885 [Opn->Csd]: mail() causes apache2 to crash when message is empty, and headers is non-empty
ID: 25885 Updated by: sniper@php.net Reported By: ben at krackeler dot com -Status: Open +Status: ... -
#25885 [NEW]: mail() causes apache2 to crash when message is empty, and headers is non-empty
From: ben at krackeler dot com Operating system: WinXP PHP version: 4.3.3 PHP Bug Type: Mail related Bug description: ... -
checking the return value of member function with empty
I am having this rather annoying syntax problem. I have this.. if (!empty($this->GetParam('someparameter')) { // OK do something since the... -
Why if(isset($_POST)) is true when its empty...
Folks, At the begining of my html I have a PHP insert which should be called when the user submits the form that the html contains... I found...



Reply With Quote

