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
  • Detect whether a variable is a scalar is_scalar

    is_scalar

    Detectwhetheravariab
  • Detect whether the variable is set and is not null isset

    isset

    Detectwhetherthevari
  • Detect whether a variable is an integer is_int

    is_int

    Detectwhetheravariab
  • Get the floating point value of the variable floatval

    floatval

    Getthefloatingpointv
  • Get the string value of the variable strval

    strval

    Getthestringvalueoft
  • Generate a representation of a storable value serialize

    serialize

    Generatearepresentat
  • Output or return a string representation of a variable var_export

    var_export

    Outputorreturnastrin
  • Detect whether the variable is null is_null

    is_null

    Detectwhetherthevari
Popular Articles