How can I write a statement that calls multiple methods of a class? For example, $ this-& gt; m_button6PaneInfo-& gt; Movable (& nbsp; false & nbsp;)-& gt; Dock ()-& gt; Fixed () -& gt; BottomDockable (& nbsp; false & nbsp;)-& gt; TopDockable (& nbsp; false & nbs calls multiple methods of a class in one line of statements, how to write?
For example:
$this->m_button6PaneInfo->Movable( false )->Dock()->Fixed()->BottomDockable( false )->TopDockable( false )->Layer( 10 )->ToolbarPane();
$ This-> m_button6PaneInfo is a class instance. The following are all methods of this class.
This statement cannot be passed, at least in my php version.
In addition to splitting multiple rows, how can this line be modified? Can it be correctly executed?
Or to which version? Can be written in this way
------ Solution --------------------
Write in this way
class testcls{
function fun1(){
echo 'fun1';
return $this;
}
function fun2(){
echo 'fun1';
return $this;
}
function fun3(){
echo 'fun3';
return $this;
}
}
$test = new testcls();
$test->fun1()->fun2()->fun3();
------ Solution --------------------
The premise of a chained operation. each operation returns the object itself.