abstract:shop.php<?php/** * Created by PhpStorm. * User: Administrator * Date: 2019/5/21 * Time: 11:11 */class Shop{ public $name; public $price; pub
shop.php
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/5/21
* Time: 11:11
*/
class Shop
{
public $name;
public $price;
public $catid;
public $lei='shop';
public function __construct($name,$price,$catid)
{
$this->name=$name;
$this->price=$price;
$this->catid=$catid;
}
function getDetail(){
return '商品名称'.$this->name."<br>".'商品价格'.':'.$this->price.'<br>'.'商品分类'.":".$this->catid;
}
}
car.php
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/5/21
* Time: 11:11
*/
class Car
{
public $name;
public $price;
public $catid;
public $lei='car';
public function __construct($name,$price,$catid)
{
$this->name=$name;
$this->price=$price;
$this->catid=$catid;
}
function getDetail(){
return '商品名称'.$this->name."<br>".'商品价格'.':'.$this->price.'<br>'.'商品分类'.":".$this->catid;
}
}
new.php
<?php
header("Content-type: text/html; charset=utf-8");
date_default_timezone_set("PRC");
spl_autoload_register(function ($className){
include __DIR__.'/commonClass/'.$className.'.php';
});
$shop = new Shop('上衣',23,'服装');
echo $shop->getDetail(),'<br>';
echo $shop->lei;echo "<br>";
$car = new Car('大众','30万','奔腾');
echo $car->getDetail();echo "<br>";
echo $car->lei;
?>
Correcting teacher:查无此人Correction time:2019-05-22 09:16:22
Teacher's summary:完成的不错,学习完类,就相当于php入门了。继续加油。