# 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: $data[] = '<script type="text/javascript">' . 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;
Tags:
46 replies
1. JC says:

HUGE THANKS ! :)

2. Juan Alejandro Opayome says:

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. Reply 3. Vishal Rana says: I am getting these errors – Fatal error: Uncaught Error: [] operator not supported for strings in C:\xampp\htdocs\wordpress\wp-content\plugins\revslider\includes\framework\base-admin.class.php:71 Stack trace: #0 C:\xampp\htdocs\wordpress\wp-content\plugins\revslider\admin\revslider-admin.class.php(572): RevSliderBaseAdmin::addMetaBox(‘Revolution Slid…’, ”, Array, NULL) #1 C:\xampp\htdocs\wordpress\wp-content\plugins\revslider\admin\revslider-admin.class.php(73): RevSliderAdmin->addSliderMetaBox() #2 C:\xampp\htdocs\wordpress\wp-content\plugins\revslider\admin\revslider-admin.class.php(44): RevSliderAdmin->init() #3 C:\xampp\htdocs\wordpress\wp-content\plugins\revslider\revslider.php(164): RevSliderAdmin->__construct(‘C:\\xampp\\htdocs…’) #4 C:\xampp\htdocs\wordpress\wp-admin\includes\plugin.php(2141): include(‘C:\\xampp\\htdocs…’) #5 C:\xampp\htdocs\wordpress\wp-admin\plugins.php(175): plugin_sandbox_scrape(‘revslider/revsl…’) #6 {main} thrown in C:\xampp\htdocs\wordpress\wp-content\plugins\revslider\includes\framework\base-admin.class.php on line 71 Reply 4. amir says: 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 Reply 5. Lydia says: Thanks ! Reply 6. Giovanni Fedele says: 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;
}

7. Janus Allen Capili says:

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!

Sometimes an error catches you where you least expect it, on localhost :) Great to hear you’ve fixed it!

8. Paul Schmidt says:

Great work, this saved me much time fixing some errors on an WordPress page.

9. Jak says:

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.

Perfecto!!!, adios al error. Muchísimas gracias.

10. Imanol says:

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;

11. David Dominguez says:

Sounds Good, but the I put the debug to 1 in my configuration.php but dont show me what is line number

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.

12. Keenan Flogerzi says:

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. Flo Sokol says:

I changed public $debug to ‘1’ but it still only shows the original error (“[] operator not supported for strings”). What can I do? Reply • Jan Reilink says: That may depend on your hosting environment and PHP settings, you’d best contact your hosting provider. Reply 14. Alejandro Ferguson says: 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. Reply 15. Wordpress Hostage says: HERO! Thanks for this post. IT WORKED! Reply 16. fahadali says: 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?? Reply 17. Walter Munoz says: Dude!!! Thank you!!! Reply 18. Dustin says: 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 Reply • Jan Reilink says: 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.

19. Magda says:

Yay, it worked like a charm for my REV slider.

Thanks!

20. poggio del falco says:

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.

21. poggio del falco says:

Good evening this is our error :
We cann’t enter on my sites on WordPress.
Can you hel us?

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!

22. David says:

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?

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
#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.

23. jefferson says:

thank you very much

24. Nicolas PLOQUIN says:

Many thanks! :)

25. Sam Torres says:

Total lifesaver given our host has forced to update to PHP 7.2! Thank you!

26. Venkatesha K says:

Thanks a lot.
saved my day.

very easy and understanding guidance.

27. Pia Jensen says:

Thank you!
Having very little experience with fixing PHP errors this was a great guide – my issue was with the Revslider in WP.

28. Sushil A. says:

Thanks! You saved my day!

29. Magnus says:

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.