PHP Syntax Keywords instanceof


- Info:

- instanceof keyword is used to determine whether an object:

- is an instance of a given class,

- is an instance of a subclass of a given class

- implements given interface.

- Class name should not be surrounded by qoutes.

- If comparison fails, the script will abort execution.


- Example:

- Create PHP Console Application Test.php.




class Person { }

$john = new Person();

if ($john instanceof Person) echo "Yes";