note 82849 added to functions.arguments
| From: | thekog at bellsouth dot net | Date: | Tue, 29 Apr 2008 11:46:13 +0000 |
| Subject: | note 82849 added to functions.arguments | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138894@lists.php.net to get a copy of this message | ||
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?
----
Server IP: 69.147.83.197
Probable Submitter: 71.199.225.31
----
Manual Page -- http://www.php.net/manual/en/functions.arguments.php
Edit -- https://master.php.net/note/edit/82849
Del: integrated -- https://master.php.net/note/delete/82849/integrated
Del: useless -- https://master.php.net/note/delete/82849/useless
Del: bad code -- https://master.php.net/note/delete/82849/bad+code
Del: spam -- https://master.php.net/note/delete/82849/spam
Del: non-english -- https://master.php.net/note/delete/82849/non-english
Del: in docs -- https://master.php.net/note/delete/82849/in+docs
Del: other reasons-- https://master.php.net/note/delete/82849
Reject -- https://master.php.net/note/reject/82849
Search -- https://master.php.net/manage/user-notes.php