|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-05-22 20:20 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2015-05-22 20:20 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 09:00:01 2025 UTC |
Description: ------------ I found this issue when testing a Magento 1.9 application. Using array elements to call a method on an object doesn't work in php7, but used to work in php5. I made a simplified example in the test script below. Test script: --------------- <?php class Item { public function save() { echo 'saved'; } } $callback = [new Item(), 'save']; // This works on both php5 and php7 $method = $callback[1]; $callback[0]->$method(); // This works on php5 only $callback[0]->$callback[1](); Expected result: ---------------- Expected "savedsaved" output. Actual result: -------------- saved Notice: Array to string conversion in /var/www/test/array_function.php on line 15 Notice: Undefined property: Item::$Array in /var/www/test/array_function.php on line 15 Fatal error: Function name must be a string in /var/www/test/array_function.php on line 15