Your Location is: Home > Php

Magento Error: Function name must be a string in

From: Moldova, View: 4686 muster 

Question

Hello i have following error, can someone help me with what to do? many thanks for your help

Fatal error: Uncaught Error: Function name must be a string in /home/httpd/vhosts/domain/shop.domain/app/code/core/Mage/Core/Model/Layout.php:529 Stack trace: #0 /home/httpd/vhosts/domain/shop.domain/app/code/core/Mage/Core/Controller/Varien/Action.php(391): Mage_Core_Model_Layout->getOutput() #1 /home/httpd/vhosts/domain/shop.domain/app/code/core/Mage/Cms/Helper/Page.php(132): Mage_Core_Controller_Varien_Action->renderLayout() #2 /home/httpd/vhosts/domain/shop.domain/app/code/core/Mage/Cms/Helper/Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), 'shopper_home_2c...') #3 /home/httpd/vhosts/domain/shop.domain/app/code/core/Mage/Cms/controllers/IndexController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), 'shopper_home_2c...') #4 /home/httpd/vhosts/domain/shop.domain/app/code/core/Mage/Core/Controller/Varien/Action.php(420): Mage_Cms_IndexContro in /home/httpd/vhosts/domain/shop.domain/app/code/core/Mage/Core/Model/Layout.php on line 529

Best answer

It happens because in PHP 7 you need to clarify that you are going to call the $callback variable as a method (function). So, the original line of the code looks like the following (file app/code/core/Mage/Core/Model/Layout.php):

$out .= $this->getBlock($callback[0])->$callback[1]();

In order to make it work on the latest PHP version we need to replace this piece of code by this one:

$out .= $this->getBlock($callback[0])->{$callback[1]}();

I hope it's helpful for you