Instanceof and is in PHP

Source: Internet
Author: User

In general PHP instanceof and is_a () function is the same, the difference is due to the different versions of PHP, some PHP version of the is_a () to give a detailed analysis of the following.

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

If yes, return TRUE, not return FALSE

Difference:

The instanceof operator is introduced in PHP 5. Prior to this use Is_a (), but later is_a () was discarded and replaced with instanceof.

Attention:

PHP 5.3.0, and restore the use of is_a ().

Summarize:

Now the service environment of PHP is commonly used php5.0+, so try to use instanceof instead of is_a ()

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

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.