Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I NOT autoload a class in php?

the autoloader at the beginning of my php code

function __autoload($class_name) {
    include_once $class_name . '.class.php';
}

is causing a call to new MongoClient(); to fail with the error Warning: include_once(MongoClient.class.php): failed to open stream

How can I use the autoloader for my classes and still use the standard classes?

Note: MongoDb has been installed with PECL and works fine with the autoloading function removed. mongo-1.3.0beta2 on php 5.4.9

like image 628
Isius Avatar asked Aug 08 '26 10:08

Isius


1 Answers

PHP will not try to autoload anything that is in the stl (like PDO, mysqli, etc)

If MongoClient is not one of those types of classes, it will try to autoload it.

Make sure you have PECL installed

like image 159
Naftali Avatar answered Aug 10 '26 01:08

Naftali



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!