php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70908 function name must be string
Submitted: 2015-11-13 09:33 UTC Modified: 2015-11-13 12:25 UTC
From: hebxiaojb at 163 dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.0.0RC7 OS: CentOS
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hebxiaojb at 163 dot com
New email:
PHP Version: OS:

 

 [2015-11-13 09:33 UTC] hebxiaojb at 163 dot com
Description:
------------
PHP Notice:  Array to string conversion in /data/x.php on line 11
PHP Notice:  Undefined property: x::$Array in /data/x.php on line 11
PHP Fatal error:  Uncaught Error: Function name must be a string in /data/x.php:11
Stack trace:
#0 {main}
  thrown in /data/x.php on line 11

Test script:
---------------
<?php
class x {
    function x() {
    }
    function common() {
    }
}

$x = new x();
$arr = ['x', 'common'];
$x->$arr[1]();

Actual result:
--------------
PHP Notice:  Array to string conversion in /data/x.php on line 11
PHP Notice:  Undefined property: x::$Array in /data/x.php on line 11
PHP Fatal error:  Uncaught Error: Function name must be a string in /data/x.php:11
Stack trace:
#0 {main}
  thrown in /data/x.php on line 11

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-11-13 10:46 UTC] laruence@php.net
use $x->{$arr[1]}();
 [2015-11-13 12:25 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: PHP Language Specification +Package: *General Issues
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 18:00:02 2026 UTC