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

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.