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 answersi 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
Post a Comment