check if an object is an instance of class in php

This forum covers all minor versions of PHP 7
Post Reply
User avatar
Administrator
Site Admin
Posts: 1725
Joined: Thu Mar 22, 2018 10:19 am

check if an object is an instance of class in php

Post by Administrator » Tue May 29, 2018 4:53 pm

To check if an object is an instance of a class in php use the

Code: Select all

instanceof
php keyword

Code: Select all

if ($obj instanceof A) {
   echo 'A';
}
http://php.net/manual/en/internals2.opc ... anceof.php

Post Reply