Differences between instanceof and is_a () in php _ PHP Tutorial

Source: Internet
Author: User
Difference between instanceof and is_a () in php. Differences between instanceof and is_a () in php in general, the instanceof and is_a () functions are the same in php. The difference is that some PHP versions discard is_a () next we will analyze the differences between instanceof and is_a () in php.

In general, the instanceof and is_a () functions in php are the same. The difference is that different PHP versions discard is_a (). let's analyze them in detail.

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

If yes, TRUE is returned. if not, FALSE is returned.

Differences:

The instanceof operator is introduced in PHP 5. Is_a () was used before, but is_a () was discarded and replaced with instanceof.

Note:

Since PHP 5.3.0, is_a () has been resumed.

Summary:

Currently, PHP5.0 + is widely used in PHP service environments, so try to use instanceof instead of is_a ()

To sum up, if you do not know your server environment, we recommend that you use instanceof to avoid unnecessary troubles.

Difference analysis between idea and is_a (). In general, the instanceof and is_a () functions in php are the same. The difference is that some PHP versions discard is_a () because of different PHP versions () below we...

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.