ID:          24105
 Updated by:  [EMAIL PROTECTED]
 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


-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to