Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

is_object

Checks whether a value is an object.

Syntax

is_object(mixed $value): bool

Parameters

ParameterTypeDescription
$valuemixedThe value to check.

Return value

bool`true` if the value is an object.

Examples

The result of json_decode():

<?php
 
var_dump(is_object(json_decode('{"a":1}')));
var_dump(is_object(json_decode('{"a":1}', true)));

Output:

bool(true)
bool(false)

Notes

To check for a particular class use the instanceof operator.

See also

  • is_array — Checks whether a value is an array.
  • get_class — Returns the class name of an object.
  • gettype — Returns the name of a value's type.

In the tutorial

  • Data types — The main PHP data types — strings, numbers, booleans, arrays and null.

Thanks for reading!

Donate to the site — we work hard for you.