Bug #73201 [Opn->Nab]: Cannot call a method in $objName->$arrName[$key]() form from 7.0
Edit report at https://bugs.php.net/bug.php?id=73201&edit=1
ID: 73201
Updated by: requinix@php.net
Reported by: liyangdal at gmail dot com
Summary: Cannot call a method in $objName->$arrName[$key]()
form from 7.0
-Status: Open
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: Any
PHP Version: 7.0.11
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The order of evaluation in situations like that has changed in PHP 7.
http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.variable-handling.indirect
Previous Comments:
------------------------------------------------------------------------
[2016-09-29 03:43:39] liyangdal at gmail dot com
Description:
------------
until 5.6.26, I can call a method for a object in the below form which the $value is a method in the
class:
$objName->$arrName[$key]();
but from 7.0, I got error message like:
PHP Notice: Array to string conversion in /home/xxx/test.php on line 12
PHP Notice: Undefined property: TestClass::$Array in /home/xxx/test.php on line 12
PHP Fatal error: Uncaught Error: Function name must be a string in /home/xxx/test.php:12
Stack trace:
#0 {main}
thrown in /home/xxx/test.php on line 12
Test script:
---------------
<?php
class TestClass{
function testFunc() {
echo "a\n";
}
}
$funcs = array( "a" => "testFunc");
$testObject = new TestClass();
$funcTag = "a";
$testObject->$funcs[$funcTag]();
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73201&edit=1
Thread (2 messages)