#28189 [NEW]: call_user_func, not in object context when called by class and func name

From: Date: Tue, 27 Apr 2004 18:37:59 +0000
Subject: #28189 [NEW]: call_user_func, not in object context when called by class and func name
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-58876@lists.php.net to get a copy of this message
From: hrvinnie at yahoo dot com Operating system: Debian Kernel 2.2.20-idepci PHP version: 5.0.0RC2 PHP Bug Type: Unknown/Other Function Bug description: call_user_func, not in object context when called by class and func name Description: ------------ PHP4 allowed one to call a function using call_user_func by passing in an array containing the class name and function name as strings. In PHP5RC1 and PHP5RC2, I have found the function is getting called. However, using $this-> within the function triggers a fetal error. My appologies, I was not sure what the best "Type" for this was, or if I'm crazy and doing something bone head wrong. Reproduce code: --------------- class test_call_user_func { var $created = "false"; function __construct() { $this->created = "true"; } function isCreated() { $ret = $this->created; return $ret; } } $function = array('test_call_user_func', 'isCreated'); print ("I have a return of isCreated [" . call_user_func($function) . "]" ); Expected result: ---------------- I have a return of isCreated [true] Actual result: -------------- Fatal error: Using $this when not in object context in /home/vfabello/workspace/loki/root/test3.php on line 16 -- Edit bug report at http://bugs.php.net/?id=28189&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28189&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28189&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=28189&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=28189&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=28189&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=28189&r=needscript Try newer version: http://bugs.php.net/fix.php?id=28189&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=28189&r=support Expected behavior: http://bugs.php.net/fix.php?id=28189&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=28189&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=28189&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=28189&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28189&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=28189&r=dst IIS Stability: http://bugs.php.net/fix.php?id=28189&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=28189&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=28189&r=float

« previous php.bugs (#58876) next »