Re: Passing large object between methods
| From: | mrfroasty | Date: | Wed, 09 Jun 2010 21:28:26 +0000 |
| Subject: | Re: Passing large object between methods | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-305997@lists.php.net to get a copy of this message | ||
> There was no text content in this message.
<?php class A{ public function someFunction() { $obj = new B(); //add more to $obj_A $obj->data = "B foo"; //call a function to add extra info on $obj_A $obj = $this->addExtraInfo($obj); //debug print_r($obj); echo "<br />"; } public function addExtraInfo($obj) { $obj->recs = "B bar"; return $obj; } } class B { public $data; public $recs; public function __construct() { } } //test $testObj = new A(); $testObj->someFunction(); ?> <?php class C{ public function someFunction() { $obj = new D(); //add more to $obj $obj->data = "D foo"; //call a function to add extra info on $obj $this->addExtraInfo($obj); //debug print_r($obj); echo "<br />"; } public function addExtraInfo(&$obj) { $obj->recs = "D bar"; } } class D { public $data; public $recs; public function __construct() { } } //test $testObj = new C(); $testObj->someFunction(); ?>
<?php class A{ public function someFunction() { $obj = new B(); //add more to $obj_A $obj->data = "B foo"; //call a function to add extra info on $obj_A $obj = $this->addExtraInfo($obj); //debug print_r($obj); echo "<br />"; } public function addExtraInfo($obj) { $obj->recs = "B bar"; return $obj; } } class B { public $data; public $recs; public function __construct() { } } //test $testObj = new A(); $testObj->someFunction(); ?> <?php class C{ public function someFunction() { $obj = new D(); //add more to $obj $obj->data = "D foo"; //call a function to add extra info on $obj $this->addExtraInfo($obj); //debug print_r($obj); echo "<br />"; } public function addExtraInfo(&$obj) { $obj->recs = "D bar"; } } class D { public $data; public $recs; public function __construct() { } } //test $testObj = new C(); $testObj->someFunction(); ?>