#24105 [Opn]: class member functions aren't first class data objects

From: Date: Tue, 10 Jun 2003 04:28:36 +0000
Subject: #24105 [Opn]: class member functions aren't first class data objects
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969354372@lists.php.net to get a copy of this message
ID: 24105 Updated by: sniper@php.net Reported By: knotwell at ix dot netcom dot com Status: Open -Bug Type: Class/Object related +Bug Type: Documentation problem PHP Version: 4.3.1 New Comment: 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(); ?> Previous Comments: ------------------------------------------------------------------------ [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

« previous php.doc (#969354372) next »