The function is_object() verifies whether a variable is an object.
bool is_object ( mixed $value )
Sr.No | Parameter | Description |
---|---|---|
1 |
value |
The variable being evaluated. |
This function returns true if value is a number or a numeric string, false otherwise. Since PHP 7.2: This function now returns true for unserialized objects without a class definition. Earlier false was returned
PHP 4 and above.
Following example demonstrates return values with different types of variables:
<?php // Create a class class tutorialsPoint { public $tp_name = "Welcome to TutorialsPoint"; } // Create the class name alias class_alias('tutorialsPoint', 'TP'); $obj1 = new tutorialsPoint(); $obj2 = new TP(); $obj3 = 'TutorialsPoint'; var_dump(is_object($obj1)); var_dump(is_object($obj2)); var_dump(is_object($obj3)); ?>
This will produce following result −
bool(true) bool(true) bool(false)