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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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: Thu Oct 08 03:00:02 2026 UTC