PHP Judgment class whether there is function class_exists usage analysis, function class_exists_php tutorial

Source: Internet
Author: User

PHP Judgment class whether there is function class_exists usage analysis, function class_exists


This paper analyzes the existence of function class_exists usage of PHP judgment class. Share to everyone for your reference. Specific as follows:

If we want to determine whether a class is available, you can use the Class_exists function first to judge, here are a few examples.

BOOL Class_exists (String $class _name [, bool $autoload = True])
Whether the given class is defined by this feature is checked. This function checks whether, or not, the given class has been defined.
Returns True if Class_name is a defined class, otherwise returns FALSE.

Examples are as follows:

Copy the Code code as follows: function __autoload ($class)
{
Include ($class. '. php ');
Check to see whether the include declared the class
if (!class_exists ($class, false)) {
Trigger_error ("Unable to load class: $class", e_user_warning);
}
}
if (class_exists (' MyClass ')) {
$myclass = new MyClass ();
}

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/911905.html www.bkjia.com true http://www.bkjia.com/PHPjc/911905.html techarticle PHP Judgment class is the existence of function class_exists usage analysis, function class_exists This article analyzes the PHP judgment class whether there is function class_exists usage. Share to everyone for your reference. ...

  • 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.