Blogger Information
Blog 25
fans 0
comment 0
visits 15876
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0807层级空间加载作业
杨发国的博客
Original
513 people have browsed it

user.php

实例

<?php
namespace controller\user;

class user
{
    public function demo()
    {
        return __CLASS__.'加载成功';
    }

}

运行实例 »

点击 "运行实例" 按钮查看在线实例

demo1.php

实例

<?php
namespace app;
use controller\user\user;
spl_autoload_register(function ($classname)
{
   $classname = str_replace('\\','/',$classname);
   require  __DIR__.'/'.$classname.'.php';
});

echo (new user)->demo();

运行实例 »

点击 "运行实例" 按钮查看在线实例

QQ截图20190811171453.png

Correction status:qualified

Teacher's comments:恭喜你终于终于搞明白了类的自动加载
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post