标签:blog io ar div on cti log ef new
<?php
/**
*
*/
class Automobile
{
private $vehicle_make;
private $vehicle_model;
public function __construct($make,$model)
{
# code...
$this->vehicle_make = $make;
$this->vehicle_model = $model;
}
public function get_make_and_model(){
return $this->vehicle_make . ‘ ‘. $this->vehicle_model;
}
}
/**
*
*/
class AutomobileFactory
{
public function create($make,$model){
return new Automobile($make,$model);
}
}
$veyron = AutomobileFactory::create(‘chuzha‘,‘love you‘);
print_r($veyron->get_make_and_model());
?>
值得注意的是调用静态方法:
AutomobileFactory::create
标签:blog io ar div on cti log ef new
原文地址:http://www.cnblogs.com/xiguain/p/4012926.html