Bug #73201 [NEW]: Cannot call a method in $objName->$arrName[$key]() form from 7.0

From: Date: Thu, 29 Sep 2016 03:43:41 +0000
Subject: Bug #73201 [NEW]: Cannot call a method in $objName->$arrName[$key]() form from 7.0
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204329@lists.php.net to get a copy of this message
From: liyangdal at gmail dot com Operating system: Any PHP version: 7.0.11 Package: Scripting Engine problem Bug Type: Bug Bug description:Cannot call a method in $objName->$arrName[$key]() form from 7.0 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 bug report at https://bugs.php.net/bug.php?id=73201&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73201&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73201&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73201&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73201&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73201&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73201&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73201&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73201&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73201&r=support Expected behavior: https://bugs.php.net/fix.php?id=73201&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73201&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73201&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73201&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73201&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73201&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73201&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73201&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73201&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73201&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73201&r=mysqlcfg

« previous php.bugs (#204329) next »