摘要:<?php spl_autoload_register(function ($className){ require __DIR__.'\inc\\'.$className.'.php'; }); //$book = new Book('《路由与交换技术》'
<?php
spl_autoload_register(function ($className){
require __DIR__.'\inc\\'.$className.'.php';
});
//$book = new Book('《路由与交换技术》','张生','网络工程','98','2018-05-01','1');
$book = new Book('《路由与交换技术》','张生','网络工程','98','2018-05-01','1');
//$book = new Book('《PHP开发宝典》','明日科技','软件工程','88','2014-03-11','1');
echo $book->title.$book->author.$book->date.$book->type.$book->price.$book->state;引用的类文件
<?php
class Book
{
public $title;
public $author;
public $date;
public $type;
public $price;
public $state;
public function __construct($title,$author,$type,$price,$date,$state)
{
$this->title = $title;
$this->author = $author;
$this->date = $date;
$this->type = $type;
$this->price = $price;
$this->state = $state;
}
}效果图:

批改老师:查无此人批改时间:2019-01-22 09:11:28
老师总结:完成的不错,参数可以给点默认值,这样传值时,就可以少传一些。加油