It's a little hard, from you code, to see what you are trying to do...
Where does the $limit variable come from? In your code above it will hold no value, and the line
if (isset($limit))
will never be true.
Also, I'm not sure why you would create a new instance of class A inside the method My_test() in class B. Since B extends A, B is kind of a instance of class A already and you probably won't need to create a new instance of it.
My guess is, that you're trying to do something like this, which should work just fine.
PHP Code:
class A { private $item_limit;
public function __construct() { $this->item_limit= null; }
public function printLimit() { echo $this->item_limit; } }
class B extends A { public function setLimit($limit) { $this->item_limit = $limit; } }
$b = new B(); $b->setLimit(12); $b->printLimit(); // should print 12
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
|