is_object
Checks whether a value is an object.
Syntax
is_object(mixed $value): boolParameters
| Parameter | Type | Description |
|---|---|---|
| $value | mixed | The 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
In the tutorial
- Data types — The main PHP data types — strings, numbers, booleans, arrays and null.