PHP instanceof vs. Is_a () detailed

Source: Internet
Author: User
In general PHP instanceof and is_a () function is the same, the difference is due to PHP version different, some PHP version of the is_a () discarded. In this paper, we will analyze the difference between instanceof and is_a () in PHP.

Both the instanceof operator and the Is_a () method are judged whether an object belongs to the class or the class is the parent of this object (used to determine whether a PHP variable belongs to an instance of a class class)

Yes returns TRUE if not, returns FALSE

Difference:

The instanceof operator was introduced in PHP 5. Before this, is_a () was used, but later is_a () was discarded and replaced with instanceof.

Attention:

PHP 5.3.0, and resumed using Is_a ().

Summarize:

PHP's service environment is now generally used php5.0+, so try to use instanceof instead of is_a ()

In summary, if you do not know your server environment, then it is recommended that you use instanceof, so as not to cause unnecessary trouble

Related recommendations:

PHP function Note

PHP basic built-in function PHP function return value PHP array php date Letter

PHP version explained _php

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.