php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71170 function name as array not working
Submitted: 2015-12-19 23:31 UTC Modified: 2015-12-19 23:34 UTC
From: dallas at ekkysoftware dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.0.1 OS: debian 8
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: dallas at ekkysoftware dot com
New email:
PHP Version: OS:

 

 [2015-12-19 23:31 UTC] dallas at ekkysoftware dot com
Description:
------------
Function name as an array element not working even though it's a string

Test script:
---------------

if(false){
//In Magento this doesn't work:-
$out .= $this->getBlock($callback[0])->$callback[1]();

//While this does
$str = $callback[1];
$out .= $this->getBlock($callback[0])->$str();
}

Expected result:
----------------
function is to be called

Actual result:
--------------
Throws exception:-


[Sun Dec 20 10:09:53.861694 2015] [:error] [pid 3622:tid 140406412060416] [client 110.174.8.215:55270] FastCGI: server "/opt/php-7.0.1/sbin/php-fpm" stderr: PHP message: PHP Fatal error:  Uncaught Error: Function name must be a string in /var/www/www.popcherry.com.au/pcmago14/source/app/code/core/Mage/Core/Model/Layout.php:555
[Sun Dec 20 10:09:53.861764 2015] [:error] [pid 3622:tid 140406412060416] [client 110.174.8.215:55270] FastCGI: server "/opt/php-7.0.1/sbin/php-fpm" stderr: Stack trace:
[Sun Dec 20 10:09:53.861777 2015] [:error] [pid 3622:tid 140406412060416] [client 110.174.8.215:55270] FastCGI: server "/opt/php-7.0.1/sbin/php-fpm" stderr: #0 /var/www/www.popcherry.com.au/pcmago14/source/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
[Sun Dec 20 10:09:53.861786 2015] [:error] [pid 3622:tid 140406412060416] [client 110.174.8.215:55270] FastCGI: server "/opt/php-7.0.1/sbin/php-fpm" stderr: #1 /var/www/www.popcherry.com.au/pcmago14/source/app/code/core/Mage/Cms/Helper/Page.php(137): Mage_Core_Controller_Varien_Action->renderLayout()
[Sun Dec 20 10:09:53.861795 2015] [:error] [pid 3622:tid 140406412060416] 
[client 110.174.8.215:55270] FastCGI: server "/opt/php-7.0.1/sbin/php-fpm" stderr: #2 /var/www/www.popcherry.com.au/pcmago14/source/app/code/core/Mage/Cms/Helper/Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), 'home')
[Sun Dec 20 10:09:53.861804 2015] [:error] [pid 3622:tid 140406412060416] [client 110.174.8.215:55270] FastCGI: server "/opt/php-7.0.1/sbin/php-fpm" stderr: #3 /var/www/www.popcherry.com.au/pcmago14/source/app/code/core/Mage/Cms/controllers/IndexController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), 'home')
[Sun Dec 20 10:09:53.861812 2015] [:error] [pid 3622:tid 140406412060416] [client 110.174.8.215:55270] FastCGI: server "/opt/php-7.0.1/sbin/php-fpm" stderr: #4 /var/www/www.popcherry.com.au/pcmago14/source/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Cms_IndexController->indexAction()
[Sun Dec 20 10:09:53.861821 2015] [:error] [pid 3622:tid 140406412060416] [client 110.174.8.215:55270] FastCGI: server "/opt/php-7.0.1/sbin/php-fpm" stderr: #5 /var/www/www.popcherry.com.au/pcmago14/sou...


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-19 23:34 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2015-12-19 23:34 UTC] nikic@php.net
The correct syntax for PHP 7 is $this->getBlock($callback[0])->{$callback[1]}();

See also: https://wiki.php.net/rfc/uniform_variable_syntax
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 20:00:02 2026 UTC