返回 使用spl_a...... 登陆

使用spl_autoload_register完成类的自动加载

罗湖 2019-05-22 14:46:47 1080
<?php

// include 'class/Mobile.php';
// include 'class/Car.php';

spl_autoload_register(function($className){
	require __DIR__.'\class\\'.$className.'.php';
});

$car = new Car('路虎', '揽胜', 600000);
$mobile = new Mobile('小米', '红米', '1300');
echo '<pre>';
echo $car->brand.$car->model.'的价格是:'.$car->price;
echo '<br>';
echo $mobile->brand.$mobile->model.'的价格是:'.$mobile->price;


最新手记推荐

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

全部回复(0)我要回复

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