Current Location: Home> Function Categories> is_object

is_object

Detect whether a variable is an object
Name:is_object
Category:Variable processing
Programming Language:php
One-line Description:Check whether the variable is an object.

Definition and usage

is_object() function checks whether the variable is an object.

If the variable is an object, the function returns true (1), otherwise false / no return value.

Example

Check whether the variable is an object:

 <?php
function get_cars ( $obj ) {
  if ( ! is_object ( $obj ) ) {
    return false ;
  }
return $obj -> cars ;
}

$obj = new stdClass ( ) ;
$obj -> cars = array ( "Volvo" , "BMW" , "Audi" ) ;

var_dump ( get_cars ( null ) ) ;
echo "<br>" ;
var_dump ( get_cars ( $obj ) ) ;
?>

Try it yourself

grammar

 is_object ( variable ) ;
parameter describe
variable Required. Specifies the variable to check.
Similar Functions
  • Free the given variable unset

    unset

    Freethegivenvariable
  • is_float alias is_real

    is_real

    is_floatalias
  • Detect whether the variable is null is_null

    is_null

    Detectwhetherthevari
  • Detect whether a variable is an array is_array

    is_array

    Detectwhetheravariab
  • is_int alias is_long

    is_long

    is_intalias
  • Get the type of variable gettype

    gettype

    Getthetypeofvariable
  • Print variables in an easy to understand format print_r

    print_r

    Printvariablesinanea
  • Print variable related information var_dump

    var_dump

    Printvariablerelated
Popular Articles