This code throws a waring under PHP 7.1.6... Under PHP 5.x.x it does not have any problems.
The offending line is $attributes['onclick'] = $onclick;, with the warning Illegal string offset 'onclick'.
Here is my code:
protected function js_anchor($title, $onclick = '', $attributes = '')
    {
        if ($onclick)
        {
            $attributes['onclick'] = $onclick;
        }
        if ($attributes)
        {
            $attributes = _parse_attributes($attributes);
        }
        return '<a href="javascript:void(0);"'.$attributes.'>'.$title.'</a>';
    }
                $attributes is initialized as an empty string. You need to make it an empty array, $attributes = []
protected function js_anchor($title, $onclick = '', $attributes = [])
{
    if ($onclick)
    {
        $attributes['onclick'] = $onclick;
    }
    if ($attributes)
    {
        $attributes = _parse_attributes($attributes);
    }
    return '<a href="javascript:void(0);"'.$attributes.'>'.$title.'</a>';
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With