ID: 24105
User updated by: knotwell at ix dot netcom dot com
Reported By: knotwell at ix dot netcom dot com
Status: Open
Bug Type: Documentation problem
PHP Version: 4.3.1
New Comment:
So the methodology for this is (what I presume to be)introspection, if
possible, I'd suggest the addition to the documentation address the
following similar case as well:
class z {
function b($x,$y) {
return $x*$y;
}
}
$a = new z;
$b = $a->b;
$b(3,4) --> an error from the runtime system.
Previous Comments:
------------------------------------------------------------------------
[2003-06-09 23:28:34] [EMAIL PROTECTED]
It's by design.
You're supposed to pass a string there, see below:
<?php
function generic_data_handler($specializedFn,$specializedFnData) {
return $specializedFnData->$specializedFn($specializedFnData);
}
class z {
var $x = 10;
var $y = 4;
function _mult($me) {
return($me->x * $me->y);
}
function aStupidlyContrivedExample() {
return generic_data_handler('_mult', $this);
}
}
$a = new z;
print $a->_mult($a);
// an error from the runtime system
print $a->aStupidlyContrivedExample();
?>
------------------------------------------------------------------------
[2003-06-09 19:32:10] knotwell at ix dot netcom dot com
I've checked the documentation, but it doesn't address this
issue. As a result, I'm unsure if this is a bug or by design.
Anyhow, it appears class functions aren't first class data objects.
I've included a short example leading to a
"Call to undefined function" message as a example:
<?php
function generic_data_handler($specializedFn,$specializedFnData) {
return $specializedFn($specializedFnData);
}
class z {
var $x = 10;
var $y = 4;
function _mult($me) {
return($me->x * $me->y);
}
function aStupidlyContrivedExample() {
return generic_data_handler($this->_mult,$this);
}
}
$a = new z;
print $a->_mult($a);
// an error from the runtime system
print $a->aStupidlyContrivedExample();
?>
Apologies in advance if this is common knowledge or not a bug.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24105&edit=1
--
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php