Check if a stdClass object has “entries” in PHP

Why can’t you just use

if(isset($content->images)) //Isset also will make sure $content is set
{
    
}

This way your performing checks on both entities.

As images is an object that can be iterated you can also check that.

if(isset($content->images) && is_object($content->images))
{
    
}

Also you seem to be using the wrong comparison operators for boolean’s, you should be using the strict standards for comparison, which is ===, and not ==, or !==, and not !=🙂

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)