时间:2021-07-01 10:21:17 帮助过:28人阅读
class test {
private $_name = '';
public function setName($name)
{
$this->_name = $name;
return $this;
}
public function getName()
{
echo $this->_name . "\n";
return $this;
}
}
$link = new test();
// 方法链
$link->setName('name1')->getName()->setName('name2')->getName()->setName('name3')->getName();
结果如下:
代码如下:
name1
name2
name3
http://www.bkjia.com/PHPjc/324583.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/324583.htmlTechArticle简单示意一下: 代码如下:
?php class test { private $_name = ''; public function setName($name) { $this-_name = $name; return $this; } public function getName...