所以我想制作和反对(例如人),其中包含一些信息,如id,name和地址,但因为人不是唯一需要此参数的对象,我创建了另一个类对于它这样的问题是我得不到任何回报只是一个空白页面没有错误或任何东西:
class address
{
public $city;
public $street;
public $alley;
public function setcity($city)
{
$this->city=$city;
}
public function getcity()
{
return $this->city;
}
public function setstreet($street)
{
$this->street=$street;
}
public function getstreet()
{
return $this->street;
}
public function setalley($alley)
{
$this->alley=$alley;
}
public function getalley()
{
return $this->alley;
}}
person.php:
require_once "address.php";
class person
{
public $id;
public $name;
public $st_id;
public $address;
public function __construct()
{
$this->address=new address();
}
public function __call($name, $arguments)
{
if(method_exists($this->address,$name))
{
return call_user_func_array(array($this->address,$name),$arguments);
}
}
/* public function printm()
{
print $this->name. " ".$this->address->city. " ".$this->address->street. " ".$this->address->alley;
}*/}