ainoy31 Posted November 25, 2008 Share Posted November 25, 2008 Hello- I have a return object of the following: stdClass Object( [out] => stdClass Object()) I have tried using the empty() function to check if this is empty but no luck. I have searched the web and no luck yet. Any suggestions? Thank. AM Link to comment https://forums.phpfreaks.com/topic/134236-returned-object/ Share on other sites More sharing options...
rhodesa Posted November 25, 2008 Share Posted November 25, 2008 As of PHP 5' date=' objects with no properties are no longer considered empty.[/quote'] Try this: <?php function isObjectEmpty ( $obj ) { foreach((array)$obj as $key=>$val){ if(is_object($val)){ if(!isObjectEmpty($val)) return false; }elseif(!empty($val)) return false; } return true; } $var = new stdClass(); $var->out = new stdClass(); if(isObjectEmpty($var)) die("Empty"); print_r($var); ?> Link to comment https://forums.phpfreaks.com/topic/134236-returned-object/#findComment-698799 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.