note 104292 added to function.call-user-func
| From: | blakerenton09 at yahoo dot com | Date: | Mon, 06 Jun 2011 11:45:33 +0000 |
| Subject: | note 104292 added to function.call-user-func | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180297@lists.php.net to get a copy of this message | ||
call_user_func may also be used to call a closure or anonymous function that has been passed into a
user-defined function.
<?php
function Benchmark()
{
foreach(func_get_args() as $function)
{
$st = microtime(true);
call_user_func($function);
$et = microtime(true);
echo sprintf("Time: %f", $et - $st) . '<br />';
}
}
Benchmark(function()
{
for ( $i = 0; $i <= 10000; $i++ )
{ }
},
function()
{
$i = 0;
while ( $i <= 10000 )
{
$i++;
}
});
?>
Returns:
Time: 0.001652
Time: 0.001458
----
Server IP: 69.147.83.197
Probable Submitter: 68.12.78.84
----
Manual Page -- http://www.php.net/manual/en/function.call-user-func.php
Edit -- https://master.php.net/note/edit/104292
Del: integrated -- https://master.php.net/note/delete/104292/integrated
Del: useless -- https://master.php.net/note/delete/104292/useless
Del: bad code -- https://master.php.net/note/delete/104292/bad+code
Del: spam -- https://master.php.net/note/delete/104292/spam
Del: non-english -- https://master.php.net/note/delete/104292/non-english
Del: in docs -- https://master.php.net/note/delete/104292/in+docs
Del: other reasons-- https://master.php.net/note/delete/104292
Reject -- https://master.php.net/note/reject/104292
Search -- https://master.php.net/manage/user-notes.php