PHP is_object Function

What is is_object() in PHP?

Explanation

is_object function checks whether the given input value is object or not.

Syntax:


is_object(variable)

Example :


<?php
function get_val($obj)
{
if(!is_object($obj))
{
return(false);
}
return($obj->websites);
}
$obj = new stdClass;
$obj->websites = Array('Hiox', 'Hscripts', 'jqslider');
var_dump(get_val(NULL));
var_dump(get_val($obj));
?>

Result :
bool(false)
array(3) { [0]=> string(4) "Hiox" [1]=> string(8) "Hscripts" [2]=> string(8) "jqslider" }

Check if a variable is an object using PHP is_object function.

PHP Topics


Ask Questions

Ask Question