Heim  >  Artikel  >  Backend-Entwicklung  >  Typecho中Typecho_Common::init()方法的疑惑

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

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

<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 的魔术方法当加载的类不存在的时候会执行此函数来加载类。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn