小编sos*_*iel的帖子

PHP自动加载功能

我想自动加载函数,而不是类.错误:

PHP致命错误:无法在第7行的/var/www/localhost/proba-function.php中重新声明proba()(之前在/var/www/localhost/proba-function.php:5中声明)

index.php代码:

class ASD {
    function __construct () {
        self::proba();
    }

    public static function __callStatic ( $name, $arguments ) {
        $foo = false;
        $directories = array_diff ( scandir ( __DIR__ ), array ( '..' ) );

        foreach ( $directories as $directory ) {
            $directory = __DIR__ . DIRECTORY_SEPARATOR . $directory;
            if ( is_dir ( $directory ) ) {
                $file = $directory . DIRECTORY_SEPARATOR . strtolower ( $name ) . '-function.php';
                if ( file_exists ( $file ) ) {
                    include …
Run Code Online (Sandbox Code Playgroud)

php function autoload

1
推荐指数
1
解决办法
309
查看次数

标签 统计

autoload ×1

function ×1

php ×1