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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 08:01:30 2024 UTC