Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
<?php
namespace api;
// 引入类的自动加载器
require 'api/auooloader.php';
$res_1 = new controller\D1();
$res_2 = new controller\D2();
$res_3 = new controller\D3();
echo $res_1->index();
echo '<hr/>';
echo $res_2->one();
echo '<hr/>';
echo $res_3->index_all();
<?php
// 自动加载器
spl_autoload_register(function ($class) {
require $class.'.php';
});
<?php
namespace api\controller;
class D1
{
public function index(){
return __CLASS__.'类'.__METHOD__.'方法';
}
}
<?php
namespace api\controller;
class D2
{
public function one(){
return __CLASS__.'类'.__METHOD__.'方法';
}
}
<?php
namespace api\controller;
class D3
{
public function index_all(){
return __CLASS__.'类'.__METHOD__.'方法';
}
}