Easy Tutorial
❮ Func Filesystem Pathinfo Php Oop ❯

PHP is_object() Function

PHP Available Functions

The is_object() function is used to check if a variable is an object.

PHP Version Requirements: PHP 4, PHP 5, PHP 7

Syntax

bool is_object ( mixed $var )

Parameter Description:

Return Value

Returns TRUE if the specified variable is an object, otherwise returns FALSE.

Example

<?php
function get_subjects($obj_name)
{
    if(!is_object($obj_name))
    {
        return(false);
    }
    return($obj_name->subjects);
}
$obj_name = new stdClass;
$obj_name->subjects = Array('Google', 'tutorialpro', 'Facebook');
var_dump(get_subjects(NULL));
var_dump(get_subjects($obj_name));
?>

Output:

bool(false)
array(3) {
  [0]=>
  string(6) "Google"
  [1]=>
  string(6) "tutorialpro"
  [2]=>
  string(8) "Facebook"
}

PHP Available Functions

❮ Func Filesystem Pathinfo Php Oop ❯