function - How to create chainable class methods in PHP -



function - How to create chainable class methods in PHP -

this question has reply here:

method chains php oop 3 answers

i need help in php create multi-dimensional classes , functions.

i need phone call function this:

$app = new class1(); $app->function1()->subfunction1()->subfunclevel2();

i've many variants nil seems work.

in javascript, create methods this:

(function($){ function class1(){ var function1 = function(){ var subfunction1 = function(){ }; }; }; });

so phone call this:

$.class1.function1.subfunction1();

i'm not sure how accomplish php.

i think you're asking method chaining? can homecoming reference object in each function this.

class class1 { public function method1() { echo "method1"; homecoming $this; } public function method2() { echo "method2"; homecoming $this; } } $class1_inst = new class1(); $class1_inst->method1()->method2(); // method1method2

php function class

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -