Illegal string offset 'class'

I think you are trying to index a string, can you paste your view code here I would like to see your widget config.

how about this error?

Illegal string offset ‘href’

  1. in yiisoft\yii2\helpers\BaseHtml.php at line 412

403404405406407408409410411412413414415416417418419420421 * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].

 * If a value is null, the corresponding attribute will not be rendered.

 * See [[renderTagAttributes()]] for details on how attributes are being rendered.

 * @return string the generated hyperlink

 * @see \yii\helpers\Url::to()


public static function a($text, $url = null, $options = [])


    if ($url !== null) {

        $options['href'] = Url::to($url);


    return static::tag('a', $text, $options);


its very basicly usage Html::a(‘name’, ‘url’, [opt]);

but i got same illegal error…

btw im using yii2 ver

Its the same error, you are trying to index a string which is not allowed in php.

// your options should be an associative array also known as hash/dictionary like so

Html::a('name', 'url', [

    'key' => 'value'


if you still get this error can you paste you code here for the link, these are basic php constructs you should know before you jump into any framework let alone yii.

use core\helpers\Html;

$left = [];

$right = [];

$widgets = [


        'class' => 'core\widgets\dashboard\Info',

        'position' => 'left',

        'options' => '',



        'class' => 'core\widgets\dashboard\Comments',

        'position' => 'right',

        'options' => '',



foreach($widgets as $widget){

    if($widget['position'] == 'left'){

        $left[] = $widget;


    if($widget['position'] == 'right'){

        $right[] = $widget;



$content = Html::beginTag('div', ['class' => 'row']);

$content .= '<div class="col-lg-6 connectedSortable">';

foreach($left as $widget){

    $class = $widget['class'];

    $content .= $class::widget($widget['options']);


$content .= '</div>';

$content .= '<div class="col-lg-6 connectedSortable">';

foreach($right as $widget){

    $class = $widget['class']

    $content .= $class::widget($widget['options']);


$content .= '</div>';

$content .= Html::endTag('div');

echo $content;

problem solved $widget[‘options’] should be declare as array. thanks alrazi