Home  >  Article  >  Backend Development  >  Typecho中Typecho_Common::init()方法的疑惑

Typecho中Typecho_Common::init()方法的疑惑

WBOY
WBOYOriginal
2016-06-06 20:37:521427browse

<code>public static function init()
{
    /** 设置自动载入函数 */
    if (function_exists('spl_autoload_register')) {
        spl_autoload_register(array('Typecho_Common', '__autoLoad'));
    } else {
        function __autoLoad($className) {
            Typecho_Common::__autoLoad($className);
        }
    }
}
</code>

上面的静态方法else里是什么意思,定义了一个函数,但没有调用它能执行吗?没看懂求解答

回复内容:

<code>public static function init()
{
    /** 设置自动载入函数 */
    if (function_exists('spl_autoload_register')) {
        spl_autoload_register(array('Typecho_Common', '__autoLoad'));
    } else {
        function __autoLoad($className) {
            Typecho_Common::__autoLoad($className);
        }
    }
}
</code>

上面的静态方法else里是什么意思,定义了一个函数,但没有调用它能执行吗?没看懂求解答

http://php.net/manual/zh/function.autoload.php

PHP 的魔术方法当加载的类不存在的时候会执行此函数来加载类。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn