The type operator instanceof does not seem to be mentioned in some PHP books. In the detailed description of PHP, it is only mentioned without going into details. I will excerpt it from the manual for notes.
The instanceof operator was introduced in PHP 5. Before this, was_a() was used, but is_a() is obsolete. It is better to use instanceof.
1. Used to determine whether a variable belongs to an instance of a certain class;
2. Used to determine whether a variable is an instance of a subclass inherited from a certain parent class;
3. Used to determine whether a variable is an instance of an object that implements a certain interface.
Prior to PHP 5.1.0, instanceof would call __autoload() if the class name to be checked did not exist. Additionally, a fatal error is generated if the class is not loaded. You can get around this problem by using a dynamic class reference or a string variable containing the class name:
Example #6 Avoid class name lookup and fatal errors caused by instanceof in PHP 5.0
$d = 'NotMyClass';
var_dump($a instanceof $d); // no fatal error here
?>
http://www.bkjia.com/PHPjc/477770.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477770.htmlTechArticleThe type operator instanceof does not seem to be mentioned in some PHP books. It is only mentioned in the detailed PHP book. If I don’t go into details, I will excerpt from the manual for notes. The instanceof operator is PH...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn