Check type of object php
(PHP 4, PHP 5, PHP 7, PHP 8) Show gettype — Get the type of a variable Descriptiongettype(mixed Parametersvalue The variable being type checked. Return ValuesPossible values for the returned string are:
Changelog
ExamplesExample #1 gettype() example
= array(1, 1., NULL, new stdClass, 'foo'); The above example will output something similar to: integer double NULL object string See Also
Anonymous ¶ 7 months ago
(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 ¶ 10 years ago
corychristison[aT-]lavacube(.dot)com ¶ 17 years ago
test( ) corychristison[aT-]lavacube(.dot)com ¶ 17 years ago
wadih at creationmw dot com ¶ 5 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
shadow_games at abv dot bg ¶ 8 years ago
Senthryl ¶ 13 years ago
gregdangelo at gmail dot com ¶ 14 years ago
How do you check if an object is an instance of a class PHP?The instanceof keyword is used to check if an object belongs to a class. The comparison returns true if the object is an instance of the class, it returns false if it is not.
How do you check the datatype of a variable in PHP?The gettype() function is an inbuilt function in PHP which is used to get the type of a variable. It is used to check the type of existing variable. Parameter: This function accepts a single parameter $var. It is the name of variable which is needed to be checked for type of variable.
What is __ method __ in PHP?"Method" is basically just the name for a function within a class (or class function). Therefore __METHOD__ consists of the class name and the function name called ( dog::name ), while __FUNCTION__ only gives you the name of the function without any reference to the class it might be in.
Is stdClass a 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.
|