• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI_DB shows up in __autoload()

[eluser]Phil Sturgeon[/eluser]
I have been faffing around with using __autoload() in CodeIgniter this evening and got a weird result.

Using a clean CodeIgniter installation I added a very simple autoload into the autoload.php config file. Just to play!

function __autoload($class)
    echo $class;

This showed me a weird result. CI_DB is being echoed out in a clean 1.7.1 install... What is the reason for that?

[eluser]Pascal Kriete[/eluser]
class_exists will try __autoload before giving up. So at the end of the front controller (where we try to close the db connection), it attempts to load the database.

And since this is a "feature" you can only opt-out off in PHP 5, we can't really prevent it. CI_DB should never come up in normal usage, so it's not a huge problem.

[eluser]Phil Sturgeon[/eluser]
Weak. Fair enough then, its only one string match away from being ignored.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.