note 82849 rejected from functions.arguments by nlopess
| From: | nlopess@php.net | Date: | Tue, 29 Apr 2008 18:00:39 +0000 |
| Subject: | note 82849 rejected from functions.arguments by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-138902@lists.php.net to get a copy of this message | ||
Note Submitter: thekog at bellsouth dot net
----
This issue cropped up in a CakePHP app but I think our problem is more related to something we
don't understand about PHP. It seems invocation ofvia $this of a method in an associated class
does not properly handle arguments by reference.
In a Bait controller class (BaitController) a function foo from the Bait model class is invoked -
$this is properly instantiated:
function test()
{
Bait::foo($xxx); // works correctly
$this->Bait->foo($xxx); // does not work
}
In Bait model function foo() takes the parm by ref and sets it's value:
function foo(&$msg)
{
$msg = "HOWDY DOODY";
}
ERROR is Undefined variable: xxx ...
If you put function foo within the Bait controller class $this->foo() works fine. However if you
put it in the model Class using the $this->Bait->foo() invocation syntax seems to ignore the
parameter by reference although it does call the function. What's up with that?