|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71812 wrong code example in php doc
Submitted: 2016-03-13 06:53 UTC Modified: 2016-03-27 04:22 UTC
From: marcosptf at yahoo dot com dot br Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: ? OS: Fedora 20
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: marcosptf at yahoo dot com dot br
New email:
PHP Version: OS:


 [2016-03-13 06:53 UTC] marcosptf at yahoo dot com dot br
Hello to everyone!!!

here ===>
the docs is fine, the description about this function work is totally correct, but the code example, is wrong;

i have write a php test to this function, and i see that the code example is fine but have a mistake.

here ===>
we can see if copy + paste from official php doc the code to run in php -a terminal, the result is a warning because the function test() is call before exist.

here ===>
we can see if move the function test() to top of code, works fine

i have open a pr to test this function ====>

and open this bug to someone fix this mistake.

thanks from php-sp Brazil!!!!

Test script:

class A
    const NAME = 'A';
    public static function test() {
        $args = func_get_args();
        echo static::NAME, " ".join(',', $args)." \n";

class B extends A
    const NAME = 'B';

    public static function test() {
        echo self::NAME, "\n";
        forward_static_call_array(array('A', 'test'), array('more', 'args'));
        forward_static_call_array( 'test', array('other', 'args'));


function test() {
        $args = func_get_args();
        echo "C ".join(',', $args)." \n";


Expected result:
B more,args 
C other,args

Actual result:
B more,args 
PHP Warning:  forward_static_call_array() expects parameter 1 to be a valid callback, function 'test' not found or invalid function name in php shell code on line 8
PHP Stack trace:
PHP   1. {main}() php shell code:0
PHP   2. B::test() php shell code:1
PHP   3. forward_static_call_array() php shell code:8


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-13 07:10 UTC]
-Status: Open +Status: Feedback -Package: Documentation problem +Package: Scripting Engine problem -PHP Version: Irrelevant +PHP Version: ?
 [2016-03-13 07:10 UTC]

Are you testing with PHP 7? Looks like there were problems with 7.0.0-3 that have been fixed with 7.0.4.
 [2016-03-13 14:54 UTC] marcosptf at yahoo dot com dot br
that's my version, i'll test in another computer with php7.0.

[root@localhost ~]# php --version
PHP 5.5.26 (cli) (built: Jun 11 2015 08:25:51) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
    with Xdebug v2.2.7, Copyright (c) 2002-2015, by Derick Rethans

thanks for feedback!
 [2016-03-14 04:10 UTC]
Try without Xdebug.
 [2016-03-27 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2017-02-05 17:48 UTC] marcosptf at yahoo dot com dot br
says, this code ist fine and works

thanks for attention!
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 22 06:01:31 2024 UTC