Title: Fix for Illegal string offset PHP Warning
Last modified: February 1, 2019

---

# Fix for Illegal string offset PHP Warning

 *  [jandreasen](https://wordpress.org/support/users/jandreasen/)
 * (@jandreasen)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/fix-for-illegal-string-offset-php-warning/)
 * If you’re getting warning errors like this:
 *     ```
       Warning: Illegal string offset 'type' in /YOUR-PATH/wp-content/plugins/tc-comment-out/tc-comment-out.php on line 24
   
       Warning: Illegal string offset 'type' in /YOUR-PATH/wp-content/plugins/tc-comment-out/tc-comment-out.php on line 29
       ```
   
 * You can fix it by editing the tc-comment-out.php file to add this code as the
   first line in the first function:
 * `$attr = array();`
 * so that it looks like this:
 *     ```
       function tc_comment_out_shortcode( $attr, $content ) {
   
           /**
           THEIR COMMENT BLOCK -- DELETED FOR BREVITY
            */
   
           $attr = array();
   
           if ( ( ( is_array( $attr ) ) && ( ! array_key_exists( 'type', $attr ) ) ) || ( ! is_array( $attr ) ) ) {
               $attr['type'] = 'html';
           }
       ...etc...
       ```
   
    -  This topic was modified 7 years, 2 months ago by [jandreasen](https://wordpress.org/support/users/jandreasen/).

Viewing 1 replies (of 1 total)

 *  [Sharaz Shahid](https://wordpress.org/support/users/sharaz/)
 * (@sharaz)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/fix-for-illegal-string-offset-php-warning/#post-11627484)
 * That is right way to handle dynamic block.Please try this.
    Note: As you define
   attributes in JS same you need to define in PHP
 *     ```
       register_block_type( 'my_namespace/my_block', [
           'render_callback' => 'render_callback',
           'attributes'      => [
               'some_string' => [
                   'default' => 'default string',
                   'type'    => 'string'
               ],
               'some_array'  => [
                   'type'  => 'array',
                   'items' => [
                       'type' => 'string',
                   ],
               ]
           ]
       ] );
   
       function render_callback( $attr, $content ){
       }
       ```
   
    -  This reply was modified 6 years, 10 months ago by [Sharaz Shahid](https://wordpress.org/support/users/sharaz/).

Viewing 1 replies (of 1 total)

The topic ‘Fix for Illegal string offset PHP Warning’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/tc-comment-out_eaeaea.svg)
 * [TC Comment Out](https://wordpress.org/plugins/tc-comment-out/)
 * [Support Threads](https://wordpress.org/support/plugin/tc-comment-out/)
 * [Active Topics](https://wordpress.org/support/plugin/tc-comment-out/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tc-comment-out/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tc-comment-out/reviews/)

## Tags

 * [illegal string offset](https://wordpress.org/support/topic-tag/illegal-string-offset/)

 * 1 reply
 * 2 participants
 * Last reply from: [Sharaz Shahid](https://wordpress.org/support/users/sharaz/)
 * Last activity: [6 years, 10 months ago](https://wordpress.org/support/topic/fix-for-illegal-string-offset-php-warning/#post-11627484)
 * Status: not a support question