返回类的自动加载案......登陆

类的自动加载案例

xgh2019-04-18 18:58:34237
class Mobile

{

    public $brand; //品牌

    public $model; //型号

    public $price; //价格


    public function __construct($brand, $model, $price)

    {

        $this->brand = $brand;

        $this->model = $model;

        $this->price = $price;

    }

}


spl_autoload_register(function ($className) {

    require __DIR__ . '/public/' . $className . '.php';

});

$mobile = new Mobile('vivo', 'nex S', 5800);

echo $mobile->brand . $mobile->model . ':' . $mobile->price, '<br>';


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送