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

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -