How does PHP autoload avoid loading internal classes?

Source: Internet
Author: User
Tags autoload
When using PHP's autoload, why even PHP internal classes will be loaded, such as using pdo,autoload will try to load pdo.php. How to avoid this situation?

function __autoload($className){    require_once APP_PATH.'Controller/'.$className.'.php';}

Reply content:

When using PHP's autoload, why even PHP internal classes will be loaded, such as using pdo,autoload will try to load pdo.php. How to avoid this situation?

function __autoload($className){    require_once APP_PATH.'Controller/'.$className.'.php';}

Are you sure the class name is correct when using the PDO class? namesapce PDO to use use or write in \POD the form below. Also make sure your PDO extension has been followed and loaded properly.
The inner class is MINIT loaded at the time, takes precedence over the request, either the class name of the inner class is not written, or the extension of the inner class is not loaded.

If you use namespaces, you need to declare
use PDO;
Or when you create an object with
new \PDO

  • Related Article

    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.