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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:37:52
Original
1493 people have browsed it

<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>
Copy after login
Copy after login

上面的静态方法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>
Copy after login
Copy after login

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

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

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

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template