1

I have a method inside a class to calculate items in a submenu.

On PHP 7.0.12 it works fine, but on version 7.1.12 doesn't works.

Here the method:

// Add submenu
            if ( ! empty( $sub ) )
            {
                $entry.= str_repeat( "\t", $level +1 ) . '<ul>' . "\n";
                $entry.= $sub[ 'list' ];
                $entry.= str_repeat( "\t", $level +1 ) . '</ul>' . "\n";
            }
            
            $entry.= str_repeat( "\t", $level ) . '</li>' . "\n";
            
            $count ++;
            
            $output[ 'active' ] = $active;
            $output[ 'list' ].= $entry;
        }
        
        return $output;

And here the error message:

Fatal error: Uncaught Error: Cannot use assign-op operators with string offsets in D:\xampp7\htdocs\SVNwork\...\include\class.menu.php:369 Stack trace: #0

That is on the line 369:

$output[ 'list' ].= $entry;

Does anyone have experience with this problem? Can't figured out.

moghwan
  • 1,829
  • 2
  • 17
  • 29
achillix
  • 457
  • 4
  • 17
  • 2
    What exactly is `$output`? *Probably not an array…* – deceze Dec 23 '17 at 20:44
  • 2
    try $output['list'] = $output['list'] . $entry may help https://stackoverflow.com/questions/26838247/fatal-error-cannot-use-assign-op-operators-with-overloaded-objects-nor-string-o – daremachine Dec 23 '17 at 20:45
  • 1
    @daremachine it works like a charm! Thanks man and happy xmas :-) – achillix Dec 23 '17 at 20:58

0 Answers0