Home  >  Article  >  Backend Development  >  Office 2010 activation method can actually use method chain in PHP

Office 2010 activation method can actually use method chain in PHP

WBOY
WBOYOriginal
2016-07-29 08:47:101121browse

Just give a brief indication:

Copy the code The code is as follows:


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() ;
// Method chain
$link->setName('name1')->getName()->setName('name2')->getName()->setName('name3')-> ;getName();


The result is as follows:

Copy the code The code is as follows:


name1
name2
name3

The above introduces the office 2010 activation method. In fact, method chain can also be used in PHP, including the office 2010 activation method. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn