Autoload classes from different folders

前端 未结 12 994
不知归路
不知归路 2020-11-28 19:35

This is how I autoload all the classes in my controllers folder,

# auto load controller classes
    function __autoload($class_name) 
    {
             


        
12条回答
  •  无人及你
    2020-11-28 19:48

    Everyone is is coping and pasting things from code they got off the internet (With the exception of the selected answer). They all use String Replace.

    String Replace is 4 times slower than strtr. You should use it instead.

    You should also use full paths when including classes with autoloading as it takes less time for the OS to resolve the path.

提交回复
热议问题