Edit report at https://bugs.php.net/bug.php?id=18187&edit=1

 ID:                 18187
 Updated by:         ni...@php.net
 Reported by:        bram at totalgsm dot net
 Summary:            Consequent implementation of array referencing to
                     user method
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   any
 PHP Version:        4.2.1
-Assigned To:        
+Assigned To:        nikic
 Block user comment: N
 Private report:     N

 New Comment:

Closing as the $callable() syntax now works for array-callbacks too (as of PHP 
5.4). Instead of function_exists the function is_callable can be used.


Previous Comments:
------------------------------------------------------------------------
[2002-07-05 11:46:28] bram at totalgsm dot net

You support calling user methods using an array in the call_user_func() 
function. But related functions of call_user_func() don't support the syntax. I 
would like to see that function_exists could check if the user method exists. 

The following example code should work:

class Foo {
  function bar($what = 'world') {
    print 'Hello ' . $what;
  }
}

$a_foo = new Foo();

$user_method = array($a_foo, 'bar');

if (!function_exists($user_method)) 
  die('You shouldn\'t see this :)');

$user_method('PHP'); // Should print "Hello PHP" ofcourse.

Furthermore the implementation of the user_method calling in call_user_func is 
incorrect for referencing variabeles, which might be pretty usefull. (see 
http://bugs.php.net/bug.php?id=17309)

------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=18187&edit=1

Reply via email to