简单示意一下:
复制代码 代码如下:
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...