Title: Warning: Cannot assign an empty string to a string offset
Last modified: August 31, 2017

---

# Warning: Cannot assign an empty string to a string offset

 *  Resolved [Foxhounds](https://wordpress.org/support/users/foxhounds/)
 * (@foxhounds)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/)
 * Hi guys, unfortunately it comes to an error when running your plugin on our website
   [http://www.450heartbeats.com](http://www.450heartbeats.com)
 * It says:
    Warning: Cannot assign an empty string to a string offset in wp-includes/
   class.wp-scripts.php on line 447
 * Do you know why?
 * Thanks! Hubertus
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fwarning-cannot-assign-an-empty-string-to-a-string-offset-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 15 replies - 1 through 15 (of 15 total)

 *  [Jarryd Long](https://wordpress.org/support/users/jarryd-long/)
 * (@jarryd-long)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-9458832)
 * Hi Hubertus
 * Thank you for getting in touch with us.
 * Please confirm what version of the plugin is currently installed on your site,
   as well as what version of PHP is used on your web server?
 *  [socialchiropractor](https://wordpress.org/support/users/socialchiropractor/)
 * (@socialchiropractor)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-9571572)
 * Can you share how this was resolved? I’m having the exact same error:
    ……/public_html/
   wp-includes/class.wp-scripts.php on line 447
 *  [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [8 years, 7 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-9596199)
 * This one is definitely not resolved with the current version. That said, I do
   have some insight from what I was able to track down.
 * The line in question in the errors is from WordPress core and deals with localizing
   content for javascript. The plugin itself utilizes `wp_localize_script()` many
   times, but the code does not like empty strings for that, at least for some people
   as found here.
 * The biggest thing is that simply sometimes, the variables being passed in to `
   wp_localize_script()` are empty strings, because no value ended up being assigned
   to them. I cleared one instance of the error by simply passing in a simple space.
 * Use of some better defaults/fallbacks would be one way to handle this. I don’t
   know the plugin well enough to know what risks there may be with backwards compatibility
   there, though.
 *  [depodra](https://wordpress.org/support/users/depodra/)
 * (@depodra)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-9650649)
 * The developers just need to add an !empty conditional for $value around line 
   443… I.e:
 *     ```
       		foreach ( (array) $l10n as $key => $value ) {
       			if ( !is_scalar($value) )
       				continue;
   
       			$l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
       		}
       ```
   
 * to…
 *     ```
       		foreach ( (array) $l10n as $key => $value ) {
       			if ( !is_scalar($value) )
       				continue;
   
       			if (!empty($value)) {
       				$l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
       			}
       		}
       ```
   
 *  [Denis Lam](https://wordpress.org/support/users/spiffyd/)
 * (@spiffyd)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-9652546)
 * It’s generally not a good practice to modify core WP files. Dev needs to fix 
   some syntax in their plugin code…
 *  [geig3r](https://wordpress.org/support/users/geig3r/)
 * (@geig3r)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-9692265)
 * After digging around, this error had something to do with WP Live Chat being 
   network activated in Multisite. I network deactivated and activated on the local
   site and the error went away.
 *  [arymaynart](https://wordpress.org/support/users/arymaynart/)
 * (@arymaynart)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-9737644)
 * There was progress with this error?
 *  [TF28](https://wordpress.org/support/users/tf28/)
 * (@tf28)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-9748608)
 * We have the same problem on a multisite installation.
    No matter if network activated
   or on a single site.
 *  [Abdhesh Kumar](https://wordpress.org/support/users/abdhesh/)
 * (@abdhesh)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-9781758)
 * Warning: Cannot assign an empty string to a string offset in C:\xampp\htdocs\
   thelexiconart\wp-includes\class.wp-scripts.php on line 426
    After the plugin 
   install how to resolve please suggest me.
 *  [Casatreslobos](https://wordpress.org/support/users/casatreslobos/)
 * (@casatreslobos)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-9818864)
 * depodra solved my problem! genious!
 *  Anonymous User 14746719
 * (@anonymized-14746719)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-9852037)
 * I’m not using multisite but have the same error but only when loading via my 
   iphone. It doesn’t show on my desktop using Chrome
 * What is the fix?
 *  [karaman666](https://wordpress.org/support/users/karaman666/)
 * (@karaman666)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-10194150)
 * Thanks depodra !
 *  [axxonita](https://wordpress.org/support/users/axxonita/)
 * (@axxonita)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-10199196)
 * Hi!
 * I solved doing this:
 *     ```
       foreach ( (array) $l10n as $key => $value ) {
            if ( !is_scalar($value) || empty($value) )
               continue;
   
            $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
       }
       ```
   
 * So, any not expected value is ignored.
 * But that the best solution is, of course, to solve the problem in the plugin.
 *  [Alexandra A.](https://wordpress.org/support/users/montenegroecoadventuresorg/)
 * (@montenegroecoadventuresorg)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-10534011)
 * Hi there, same problem again today with “Cannot assign an empty string to a string
   offset in …..\wp-includes\class.wp-scripts.php on line 426”
 * [@depodra](https://wordpress.org/support/users/depodra/), can you please be so
   kind to advise me what to do here?
    Do I need to edit the file through FTP and
   change the code? Thanks in advance! Alexandra A.
 *  [depodra](https://wordpress.org/support/users/depodra/)
 * (@depodra)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-10535177)
 * Hi [@montenegroecoadventuresorg](https://wordpress.org/support/users/montenegroecoadventuresorg/)–
   as [@spiffyd](https://wordpress.org/support/users/spiffyd/) mentioned previously
   this should be fixed by the plugin developers – sad to see 11 months on this 
   hasn’t been resolved. If you fix your script and then update WordPress, your 
   fix will be overwritten. However, as a temporary resolution to the error displaying:
 * For WP 4.9.7:
 * Login to your FTP,
    Navigate to /yourwebroot/wp-includes/ and open class.wp-scripts.
   php. Navigate to line 426:
 * `$l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');`
 * Replace with:
 * `if (!empty($value)) { $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES,'
   UTF-8'); }`
    -  This reply was modified 7 years, 10 months ago by [depodra](https://wordpress.org/support/users/depodra/).
    -  This reply was modified 7 years, 10 months ago by [depodra](https://wordpress.org/support/users/depodra/).

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Warning: Cannot assign an empty string to a string offset’ is closed 
to new replies.

 * ![](https://ps.w.org/wp-live-chat-support/assets/icon-256x256.png?rev=2405258)
 * [3CX Free Live Chat, Calls & Messaging](https://wordpress.org/plugins/wp-live-chat-support/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-live-chat-support/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-live-chat-support/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-live-chat-support/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-live-chat-support/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-live-chat-support/reviews/)

 * 15 replies
 * 15 participants
 * Last reply from: [depodra](https://wordpress.org/support/users/depodra/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/warning-cannot-assign-an-empty-string-to-a-string-offset-2/#post-10535177)
 * Status: resolved