php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #22113 error in one of your documentation-examples
Submitted: 2003-02-07 13:32 UTC Modified: 2003-02-07 14:22 UTC
From: elmarto at gmx dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.0 OS: linux debian
Private report: No CVE-ID: None
 [2003-02-07 13:32 UTC] elmarto at gmx dot de
in your documentation on page http://www.php.net/manual/en/functions.variable-functions.php there is a mistake with the latest example 13.4.
it says:
<?php
class Foo
{
    function Var()
    {
        $name = 'Bar';
        $this->$name(); // This calls the Bar() method
    }
    
    function Bar()
    {
        echo "This is Bar";
    }
}

$foo = new Foo();
$funcname = "Var";
$foo->$varname();   // This calls $foo->Var()

?>

The $foo->$varname(); will produce an undefined function error.
It has to be $foo->funcname();

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-07 13:33 UTC] elmarto at gmx dot de
in your documentation on page
http://www.php.net/manual/en/functions.variable-functions.php there is a
mistake with the latest example 13.4.
it says:
<?php
class Foo
{
    function Var()
    {
        $name = 'Bar';
        $this->$name(); // This calls the Bar() method
    }
    
    function Bar()
    {
        echo "This is Bar";
    }
}

$foo = new Foo();
$funcname = "Var";
$foo->$varname();   // This calls $foo->Var()

?>

The $foo->$varname(); will produce an undefined function error.
It has to be $foo->$funcname();
 [2003-02-07 14:22 UTC] philip@php.net
This has been fixed:
http://cvs.php.net/cvs.php/phpdoc/en/language/functions.xml

It will show up when the manual is next built, thank you for the report :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Aug 16 05:01:30 2024 UTC