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;
Donate a cup of coffee
Donate a cup of coffee

Thank you very much! <3 ❤️

52 Comments

  1. Jack

    Thank you. The Revolution Slider fix your article suggested worked perfectly for me using PHP 7.4 (upgraded from 7.0).

    • Great to hear the suggested fix worked Jack, and that’s quite an impressive upgrade :-)

  2. Wow,
    After searching a lot of StackOverflow tutorial and finally your suggestions work well.
    I have fixed my array issue.
    Thanks a lot.

  3. Juan Alejandro Opayome

    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.

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

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

  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;
    }

  7. Janus Allen Capili

    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

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

  9. Jak

    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.

    • Adri

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

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

    I changed public $debug to ‘1’ but it still only shows the original error (“[] operator not supported for strings”). What can I do?

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

  14. Alejandro Ferguson

    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. Wordpress Hostage

    HERO! Thanks for this post. IT WORKED!

  16. fahadali

    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??

  17. Dustin

    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

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

  18. Magda

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

    Thanks!

  19. poggio del falco

    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

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

  20. poggio del falco

    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?

    • 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!

  21. David

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

  22. Sam Torres

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

  23. Venkatesha K

    Thanks a lot.
    saved my day.

    very easy and understanding guidance.

  24. Pia Jensen

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

  25. Sushil A.

    Thanks! You saved my day!

  26. Magnus

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *