wolves Posted April 19, 2006 Share Posted April 19, 2006 HI[code] class a { public $data; public function __construct($data) { this->data = $data; } } class b { public $itens = Array(); public function add_item($item) { $this->itens[] = new a($item); } public function get() { print_r($this->itens); } } class c { public $test = Array(); public function &do_b() { $this->test = new b(); return $this->test[sizeof($this->test)-1]; } public function get() { foreach($test as $tt ) { $tt->get(); } } } } $test = new c; $bclass = $test->do_b(); $bclass->add_item("hello"); $bclass->add_item("hi"); $test->get();[/code] ok in my machine $test->get will print "hello", "hi" ..... but at my server it not works, it's print nothing "Array()" why ? Link to comment https://forums.phpfreaks.com/topic/7863-objects-working-togther/ Share on other sites More sharing options...
ober Posted April 19, 2006 Share Posted April 19, 2006 Are the PHP versions the same? Link to comment https://forums.phpfreaks.com/topic/7863-objects-working-togther/#findComment-28702 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.