Replacement for PHP's __autoload function?

后端 未结 6 1831
攒了一身酷
攒了一身酷 2021-01-05 08:36

I have read about dynamically loading your class files when needed in a function like this:

function __autoload($className)
{
   include(\"classes/$className         


        
6条回答
  •  执笔经年
    2021-01-05 09:35

    The correct way would be to use spl_autoload_register. To save a __autoload function that some 3rd-party introduced you can put that function on the autoloader-stack as well:

    if (function_exists('__autoload')) {
        spl_autoload_register('__autoload');
    }
    

提交回复
热议问题