php - $a->b = new cl(); How to call $a->x() from within $a->b->c() without having to pass $a as an argument to c(); -
php
class cla { var $b; function cla() { $this->b = new clb(); } function x() { echo "testing"; } } class clb { function clb() { } function c ($a) { $a->x(); } } $a = new cla(); $a->b->c($a);
how call c() without having pass $a;
calling method member of object 1 level current object method being called.
function c () { ??->x(); }
?? => object 1 level current object of method member
class cla { public $b; public function __construct() { $this->b = new clb($this); } public function x() { echo "testing"; } } class clb { private $a; public function __construct($a) { $this->a = $a; } public function c () { $this->a->x(); } } $a = new cla(); $a->b->c();
note i've updated classes php5 php4
Comments
Post a Comment