How check stdclass object is empty in php?
I have this empty object
When I use How can I check it?
asked Jan 3, 2013 at 10:33
2 Cast to an array first
The reason is, that an object is an object and there is no useful definition of "an empty object", because there are enough classes out there, that only contains methods, but no properties. Should they considered as "empty"? answered Jan 3, 2013 at 10:38
KingCrunchKingCrunch 126k20 gold badges147 silver badges171 bronze badges 1 Check if But I'd better define my own class, and provide it with a meaningful answered Jan 3, 2013 at 10:39
moonwave99moonwave99 20.9k2 gold badges41 silver badges64 bronze badges 1 (PHP 4, PHP 5, PHP 7, PHP 8) is_object — Finds whether a variable is an object Descriptionis_object(mixed Parametersvalue The variable being evaluated. Return Values Returns Changelog
ExamplesExample #1 is_object() example
$obj->students; See Also
mark at not4you dot com ¶ 11 years ago
corychristison[aT-]lavacube(.dot)com ¶ 17 years ago
test( ) wadih at creationmw dot com ¶ 5 years ago
corychristison[aT-]lavacube(.dot)com ¶ 17 years ago
lbjay can be emailed at reallywow dot com ¶ 19 years ago
will ¶ 12 years ago
victor AT fourstones DOT net ¶ 17 years ago
Senthryl ¶ 13 years ago
shadow_games at abv dot bg ¶ 8 years ago
gregdangelo at gmail dot com ¶ 14 years ago
How check if object is empty PHP?PHP empty() Function
The empty() function checks whether a variable is empty or not. This function returns false if the variable exists and is not empty, otherwise it returns true. The following values evaluates to empty: 0.
How do you check if the array of objects is empty in PHP?Use count() Function to Check Whether an Array Is Empty in PHP. It is the array whose number of elements we wish to find. It can be a countable object as well.
What is stdClass object in PHP?The stdClass is the empty class in PHP which is used to cast other types to object. It is similar to Java or Python object. The stdClass is not the base class of the objects. If an object is converted to object, it is not modified.
How check variable is object or not in PHP?The is_object() function checks whether a variable is an object. This function returns true (1) if the variable is an object, otherwise it returns false/nothing.
|