PHP Type Operator

What are the Type Operator?


The only PHP type operator: instanceof is used to determine whether a given object, its parents or their implemented interfaces are of a specified object class.Before this is_a() was used but is_a() has been deprecated in favor of instanceof.

Example :

class A { }
class B { }
$like = new A;
if ($like instanceof A)
echo 'A';
if ($like instanceof B)
echo 'B';
Result :


In the above example like is an object of class A, so "A" is displayed as answer

PHP Topics

Ask Questions

Ask Question