PHP Entity
PHP引入实体进行传参与操作
PHP引入实体进行传参与操作
<?php
class Entity
{
var $_email = '@163.com';
var $_comment = 'no thing';
public function getEmail()
{
return $this->_email;
}
public function setEmail($val)
{
$this->_email = $val;
return $this;
}
public function getComment()
{
return $this->_comment;
}
public function setComment($val)
{
$this->_comment = $val;
return $this;
}
}
class Test
{
public function save(Entity $guestbook)
{
$data = array(
'email' => $guestbook->getEmail(),
'comment' => $guestbook->getComment(),
'created' => date('Y-m-d H:i:s'));
$this->data = $data;
return $this;
}
public function show()
{
print_r($this->data);
}
}
$param = new Entity();
$param->setEmail('xxx@163.com')->setComment("说撒");
$t = new Test();
$t->save($param)->show();
- 上一篇:消耗内存用的
- 下一篇:PHP获取ip对应地区和使用的网络类型
精彩图集
精彩文章






