extending class and protected data
<p>im trying to create a class to manage widgets. I have problems with a protected data in parent class:</p>

<p>Widget.php</p>

<pre><code>/** Parent class **/
class Widget{
    protected $html =""; //formated html data
    // method to load views in {system_path}/widgets/{widget_name}/views/
    protected function LoadView($filename){
        if(!empty($filename) &amp;&amp; is_string($filename)){
            $output = "";
            $dir = WIDGET_PATH . "views" . DS . $filename;
            ob_start();
                include($dir);
                $output = ob_get_contents();
            ob_end_clean();
            return $output;
        }
        return NULL;
    }

    //method to render formated html data
    public function Render(){
        if(isset($this-&gt;html) &amp;&amp; !empty($this-&gt;html)){
            return $this-&gt;html;
        }
        return NULL;
    }
    //static method to load a Widget
    public static function Load($widgetName){
        if(!empty($widgetName) &amp;&amp; is_string($widgetName)){
            $widgetName = strtolower($widgetName);
            if(file_exists(WIDGET_PATH . $widgetName . DS . $widgetName . ".php")){
                include_once(WIDGET_PATH . $widgetName . DS . $widgetName . ".php");
                if(class_exists($widgetName."_Widget")){
                    $class = $widgetName."_Widget";
                    return new $class();
                }
            }
        }
        return FALSE;
    }

}
</code></pre>

<p>/widgets/socialbar.php</p>

<pre><code>/** SocialBar Widget **/
class Socialbar_Widget extends Widget
{   
    public function __construct(){
        $this-&gt;html = "demo"; // test to see if it works
    }
}
</code></pre>

<p>index.php</p>

<pre><code>/*load class files, etc */
$Social = Widget::Load("socialbar"); //works, perfectly loads Socialbar_Widget()

var_dump($social); // works : object(Socialbar_Widget)[29] protected html = 'demo' ......

$Social-&gt;Render(); // throws Fatal error: Using $this when not in object context
</code></pre>

<p>To extend a variable inside parent class should i use "public"? Or what i mistake.
Thanks for help guys.</p>
