Is it possible to chain function calls in PHP? -


if have functions

function function1 ( $myparameter ) { ... }  function function2 ( $myparameter ) { ... }  function function3 ( $myparameter ) { ... } 

when call

function1( function2( function3( $myparameter ) ) ) 

i call this:

function3( $myparameter ) -> function2() -> function1() 

function3( $myparameter ) sent parameter function2()

a php plugin exists (or else) ?

thx

you can chained objects methods returning instance (with $this) here trivial example.

class foo {     function function1() {         echo "i'm function1\n";         return $this;     }     function function2() {         echo "i'm function2\n";         return $this;     }     function function3() {         echo "i'm function3\n";         return $this;     } }   $bar = new foo(); $bar->function3()->function2()->function1(); 

Comments

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

asp.net mvc - Cannot display error message on Editor or EditorFor -

php - Using str_replace to translate a MySQL Table in html -