You are here: Saotn.org » Code base » Fatal error: Uncaught Error: [] operator not supported for strings – PHP 7.1

# Fatal error: Uncaught Error: [] operator not supported for strings – PHP 7.1

With PHP 7.1, some PHP web applications fail because of deprecated code usage. This may result in an error message like [] operator not supported for strings for various Joomla, WordPress and Drupal components. Here’s how to fix this code for PHP 7.1+.

I’ll use Joomla as an example in this short post. The same error and fix may apply for other CMS systems like WordPress and Drupal.

First you have to enable Joomla Debug modus, that’ll show you where the error is happening. Open up configuration.php and set public $debug to 1. If you refresh the page now, you’ll see Joomla’s error page, telling you about Fatal error: Uncaught Error: Fatal error: Uncaught Error: [] operator not supported for strings D:\www\example.com\www\components\com_layer_slider\base\includes\slider_markup_init.php:98 OK, so we now know where the error is, it’s on line 98 in com_layer_slider’s base\includes\slider_markup_init.php file. In this case, the failing code is: ' . NL; You can fix this PHP error by first initializing $data[] as an array:

$data = [];$data[] = '<script type="text/javascript">' . NL;

A second method is to use the older style using array():

$data = array();$data[] = '<script type="text/javascript">' . NL;

Let’s hope not too many Joomla components, plugins and extensions use code like this. Not to mention other CMS systems like Expression Engine, WordPress, BuddyPress, PrestaShop…

Update 3-3-2018:
WordPress premium Betheme theme by Muffin group needs a fix in the file

wp-content\themes\betheme\functions\builder\front.php

On line 150:

// $section_style = '';$section_style         = [];

WordPress Revolution Slider

Older versions of WordPress plugin Revolution Slider by ThemePunch has this same deprecated PHP code, and throws an error:

Uncaught Error: [] operator not supported for strings in wp-content\plugins\revslider\includes\framework\base-admin.class.php:69

To fix this, add a line before line 69:

self::$arrMetaBoxes = []; # add this line to create the variable as an array self::$arrMetaBoxes[] = $box; ## 47 thoughts on “Fatal error: Uncaught Error: [] operator not supported for strings – PHP 7.1” 1. HUGE THANKS ! :) 2. Wow this part worked for me: self::$arrMetaBoxes = []; # add this line to create the variable as an array
self::$arrMetaBoxes[] =$box;

I had the same issue on revolution slider.

1. That’s great Juan, cheers!

2. Yes, This worked for me too.

3. I am getting these errors –

4. sir your website is so much useful for me i do thousand of ways but i cant find the solution but after visiting your site i got solution keep doing this i appreciate you

5. Thanks !

6. Magento 1.9 Webshopapps Matrix Pro module has this problem too.
For fixing it edit the file app/code/community/Webshopapps/Wsacommon/Helper/Shipping.php, line 312:

} else {
$itemGroup = [];$itemGroup[] = $item; } 1. Thanks for your addition Giovanni! 7. Very helpful and informative! One of the sites I’ve been administering has a revslider plugin. The wordpress site uses an older version of PHP. Thus, when I tried to transfer the files on my localhost that has the new version of PHP, it stumbled upon this issue. This article helped me to resolve the issue on the plugin and the site is working as expected. Thank you! 1. Sometimes an error catches you where you least expect it, on localhost :) Great to hear you’ve fixed it! 1. Cheers :) 8. Thanks – this: //$section_style = ”;
$section_style = []; also worked for the Rocco theme by MuffinGroup (for the benefit of anyone else getting to this via the Googles…) the error is thrown by rocco/functions/meta-functions.php on line 1579. 1. Perfecto!!!, adios al error. Muchísimas gracias. 9. You can fix the error by adding this line before line 71: if(!is_array(self::$arrMetaBoxes)) self::$arrMetaBoxes = array(); It should stay like this on line 71 and 72: if(!is_array(self::$arrMetaBoxes)) self::$arrMetaBoxes = array(); self::$arrMetaBoxes[] = $box; 10. Sounds Good, but the I put the debug to 1 in my configuration.php but dont show me what is line number 1. Hi David, The reason you don’t see the line number might be because of PHP’s error_reporting() settings, or .htaccess. Check your php.ini and .htaccess files and/or ask your hosting provider. Perhaps add error_reporting = E_ALL and display_errors = On to your user-defined ini or the proper php_flag to your .htaccess. 1. Thank you so much.. this work for me! 11. THANK YOU SOOO MUCCHHHH!! Perfect SOLUTION!! 12. What are the chances one of the first Google results for a generic error would have the answer for the specific theme and plugin giving me issues?! Thanks so much! 13. I changed public$debug to ‘1’ but it still only shows the original error (“[] operator not supported for strings”). What can I do?

1. That may depend on your hosting environment and PHP settings, you’d best contact your hosting provider.

14. Gracias! it works beautifully!!
i found the file to modify on this path: /wp-content/plugins/revslider/inc_php/framework
i love you man or woman whatever.

15. Fatal error: Uncaught Error: [] operator not supported for strings in C:\wamp64\www\project\wp-content\plugins\revslider\inc_php\framework\base_admin.class.php on line 72

how to solve this error??

16. The Rev Slider update worked perfectly, but I also have the Betheme and I can’t get the code change to help. Here’s the error I’m getting on Kellermandental.com:

Fatal error: Uncaught Error: [] operator not supported for strings in /home/kellerma/public_html/wp-content/themes/betheme/functions/builder/front.php:144 Stack trace: #0 /home/kellerma/public_html/wp-content/themes/betheme/page.php(24): mfn_builder_print(47) #1 /home/kellerma/public_html/wp-includes/template-loader.php(77): include(‘/home/kellerma/…’) #2 /home/kellerma/public_html/wp-blog-header.php(19): require_once(‘/home/kellerma/…’) #3 /home/kellerma/public_html/index.php(17): require(‘/home/kellerma/…’) #4 {main} thrown in /home/kellerma/public_html/wp-content/themes/betheme/functions/builder/front.php on line 144

I added your extra code to Line 143 but it didn’t fix it. Here’s what that section has now:

141 // styles ————————-
142 $section_style = ”; 143$section_style = [];
144 $section_style[] = ‘padding-top:’. intval($section[‘attr’][‘padding_top’] ) .’px’;

Any other help?

Thanks!
Dusti

1. Hi Dustin,
Great to hear the Rev Slide fix/update worked perfectly. For BeTheme (of which I don’t have a copy available), I’d comment out line 142 in wp-content/themes/betheme/functions/builder/front.php:

// $section_style =''; If that fails I recommend you contact the theme authors for a fix. 17. Yay, it worked like a charm for my REV slider. Thanks! 18. we need help about this error : Errore fatale: Errore non rilevato: [] operatore non supportato per archi in /home/cartepre/addon_domains/poggiodelfalco.com/wp-content/plugins/revslider/inc_php/framework/base_admin.class.php:73 traccia stack: # 0 / home / cartepre / addon_domains / poggiodelfalco.com / wp-content / plugins / revslider / revslider_admin.php (237) UniteBaseAdminClassRev :: addMetaBox ( ‘rivoluzione Fatto scorrere …’, Object (UniteSettingsAdvancedRev), Array, NULL) # 1 / home / cartepre / addon_domains / poggiodelfalco.com / wp-content / plugins / revslider / revslider_admin.php (68) RevSliderAdmin-> addSliderMetaBox () # 2 /home/cartepre/addon_domains/poggiodelfalco.com/wp-content/plugins/revslider/ revslider_admin.php (40): RevSliderAdmin-> init () # 3 /home/cartepre/addon_domains/poggiodelfalco.com/wp-content/plugins/revslider/revslider.php(147) RevSliderAdmin -> __ construct ( ‘/ home / cartepre / … ‘) # 4 /home/cartepre/addon_domains/poggiodelfalco.com/wp-settings.php(305): include_once ( ‘/ home / cartepre / …’) # 5 /home/cartepre/addon_domains/poggiodelfalco.com/wp -config.php (95): require_once (‘/ home / cartepre / in/home/cartepre/addon_domains/poggiodelfalco.com/wp-content/plugins/revslider/inc_php/framework/base_admin.class.php on line 73 1. If you can’t make the changes yourself, using the information from this blog post, then you can either ask your web hosting provider, and/or pursue the FTP option I mentioned. I can’t help you from here unfortunately. 19. Good evening this is our error : Fatal error: Uncaught Error: [] operator not supported for strings in /home/cartepre/addon_domains/poggiodelfalco.com/wp-content/plugins/revslider/inc_php/framework/base_admin.class.php:73 Stack trace: #0 /home/cartepre/addon_domains/poggiodelfalco.com/wp-content/plugins/revslider/revslider_admin.php(237): UniteBaseAdminClassRev::addMetaBox(‘Revolution Slid…’, Object(UniteSettingsAdvancedRev), Array, NULL) #1 /home/cartepre/addon_domains/poggiodelfalco.com/wp-content/plugins/revslider/revslider_admin.php(68): RevSliderAdmin->addSliderMetaBox() #2 /home/cartepre/addon_domains/poggiodelfalco.com/wp-content/plugins/revslider/revslider_admin.php(40): RevSliderAdmin->init() #3 /home/cartepre/addon_domains/poggiodelfalco.com/wp-content/plugins/revslider/revslider.php(147): RevSliderAdmin->__construct(‘/home/cartepre/…’) #4 /home/cartepre/addon_domains/poggiodelfalco.com/wp-settings.php(305): include_once(‘/home/cartepre/…’) #5 /home/cartepre/addon_domains/poggiodelfalco.com/wp-config.php(95): require_once(‘/home/cartepre/ in /home/cartepre/addon_domains/poggiodelfalco.com/wp-content/plugins/revslider/inc_php/framework/base_admin.class.php on line 73 We cann’t enter on my sites on WordPress. Can you hel us? 1. The fastest way is to disable the plugin entirely, for example by FTP (rename the directory). Then install a new version of the revslider plugin. The second option involves making code changes to revslider/inc_php/framework/base_admin.class.php as described in this post. What changes, and where, depends on your revslider plugin version. Try to match your file around line 73 with the code examples from this blog post. But as said, option #1 is the most simple: use FTP to rename or delete the plugin file, log on and install a new version. Goodluck! 20. Hi, I tried the revslider edit – self::$arrMetaBoxes[] = $box; – mine was on line 71. I added – self::$arrMetaBoxes = []; – above like you instructed, but I’m getting a syntax error. Could it be because on line 65 – $box = array(); – it already is labeled an array? 1. Hi David, The solution -code fix- may differ per revslider version. What does your complete error message look like? Recently one of our clients had the following error in Revolution Slider 4.6.5: Fatal error: Uncaught Error: [] operator not supported for strings in d:\sites\path\to\website\www\wp-content\plugins\revslider\inc_php\framework\base_admin.class.php:72 Stack trace: #0 d:\sites\path\to\website\www\wp-content\plugins\revslider\revslider_admin.php(157): UniteBaseAdminClassRev::addMetaBox('Revolution Slid...', Object(UniteSettingsAdvancedRev), Array, NULL) #1 d:\sites\path\to\website\www\wp-content\plugins\revslider\revslider_admin.php(68): RevSliderAdmin->addSliderMetaBox() #2 d:\sites\path\to\website\www\wp-content\plugins\revslider\revslider_admin.php(40): RevSliderAdmin->init() #3 d:\sites\path\to\website\www\wp-content\plugins\revslider\revslider.php(146): RevSliderAdmin->__construct('d:\\sites\\path\\...') #4 d:\sites\path\to\website\www\wp-admin\includes\plugin.php(1909): include('d:\\sites\\path\\...') #5 d:\sites\path\to\website\www\wp-admin\plugins.php(172): plugin_sandbox_scrape('revslider/revsl...') #6 {main} thrown in d:\sites\path\to\website\www\wp-content\plugins\revslider\inc_php\framework\base_admin.class.php on line 72 Because of this error he couldn’t log on into the WordPress Dashboard. I used the same code fix as in this post, after which he could log on again. Then we updated Revolution Slider by FTP because of other errors. 1. You’re welcome Sam, glad the article helped you. 21. Thank you! Having very little experience with fixing PHP errors this was a great guide – my issue was with the Revslider in WP. 22. Thanks a ton!! That did the trick!! 23. Thank you a million times and if I could I would give you a really big hug! Drove me crazy trying to to fix the login since we were locked out of our site and we really needed to switch a few things around asap. “WordPress Revolution Slider Older versions of Revolution Slider plugin by ThemePunch has this same deprecated PHP code, and throws an error: Uncaught Error: [] operator not supported for strings in wp-content\plugins\revslider\includes\framework\base-admin.class.php:69 To fix this, add a line before line 69: self::$arrMetaBoxes = []; # add this line to create the variable as an array
self::$arrMetaBoxes[] =$box;

Thank you once again and bookmarked for future reference.

1. Hi Magnus, you’re welcome, glad the post helped! :)

24. Legend, that fixed it :)