php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54009 wrong call_user_func_array documentation
Submitted: 2011-02-13 23:15 UTC Modified: 2011-02-14 12:45 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: duke at ejoom dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.3.5 OS:
Private report: No CVE-ID: None
 [2011-02-13 23:15 UTC] duke at ejoom dot com
Description:
------------
---
From manual page: http://www.php.net/function.call-user-func#Parameters
---

The example script made an error.

True example is:

<?php
error_reporting(E_ALL);
function increment(&$var)
{
    $var++;
}
$a = 0;
call_user_func('increment', &$a);
echo $a."\n";

call_user_func_array('increment', array(&$a)); // You can use this instead before PHP 5.3
echo $a."\n";
?>


And true output:
1
2

Bags are in line "call_user_func('increment', &$a);" and at output.

Test script:
---------------
<?php
error_reporting(E_ALL);
function increment(&$var)
{
    $var++;
}
$a = 0;
call_user_func('increment', &$a);
echo $a."\n";

call_user_func_array('increment', array(&$a)); // You can use this instead before PHP 5.3
echo $a."\n";
?>


Output:
1
2

Expected result:
----------------
1
2


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-13 23:32 UTC] duke at ejoom dot com
-Status: Open +Status: Closed
 [2011-02-13 23:32 UTC] duke at ejoom dot com
Sorry, I was wrong.
It's all OK.
 [2011-02-14 12:45 UTC] cataphract@php.net
-Status: Closed +Status: Bogus
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Dec 01 02:01:24 2020 UTC