instanceof With Variables

../_images/instanceof_with_variable.png

It is possible to compare the type of two objects with instanceof: PHP uses the class of the second operand, or the name of the class passed as a string.

Here, note that the cast operator (object) creates stdClass when applied to array.

See Also

PHP Features