note 123580 added to function.call-user-func-array
| From: | marjunebatac at gmail dot com | Date: | Sat, 02 Feb 2019 07:37:49 +0000 |
| Subject: | note 123580 added to function.call-user-func-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-210177@lists.php.net to get a copy of this message | ||
if ever you want to invoke call_user_func_array indirectly and expect a return; don't forget to
add return to it.
for example.
<?php
$func = function($arg1, $arg2) {
return $arg1 * $arg2;
};
function someFunc($func)
{
return call_user_func_array($func, array(2, 4));
}
echo someFunc($func); // 8
?>
or
<?php
class someClass
{
public function magic($args)
{
return "Hello $args";
}
public function __call($name, $arguments)
{
return call_user_func_array(
array($this, 'magic'),
$arguments
);
}
}
$someclass = new someClass();
echo $someclass->whatever("Dofy"); // Hello Dofy
?>
without a return in __call method will not output anything
----
Server IP: 208.43.231.9
Probable Submitter: 82.199.157.35 (proxied: 119.92.13.219)
----
Manual Page -- http://php.net/manual/en/function.call-user-func-array.php
Edit -- https://master.php.net/note/edit/123580
Del: integrated -- https://master.php.net/note/delete/123580/integrated
Del: useless -- https://master.php.net/note/delete/123580/useless
Del: bad code -- https://master.php.net/note/delete/123580/bad+code
Del: spam -- https://master.php.net/note/delete/123580/spam
Del: non-english -- https://master.php.net/note/delete/123580/non-english
Del: in docs -- https://master.php.net/note/delete/123580/in+docs
Del: other reasons-- https://master.php.net/note/delete/123580
Reject -- https://master.php.net/note/reject/123580
Search -- https://master.php.net/manage/user-notes.php