Jump to content

Returned Object ?


ainoy31

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.