Menu Home

is_object

osbo.com | PHP | Functions | is_object

Finds whether a variable is an object

Syntax

is_object ( mixed $var ) : bool

Parameters

var

The variable being evaluated.

Return

Returns TRUE if var is an object, FALSE otherwise.

Examples

1

<?

$var = new stdclass;

$return = is_object($var);

var_dump($var, $return);

?>
object(stdClass)#1 (0) {
}
bool(true)

2

<?

class myclass {
    function myfunction() {}
}

$var = new myclass;

$return = is_object($var);

var_dump($var, $return);

?>
object(myclass)#1 (0) {
}
bool(true)

PHP