title: PHP classses/functions
body: <p>How do I get the $str variable (below) into my class/classes?  The function is used to call each class dynamically rather tan have "lots" of if(class_exists) statements.</p>
  
  <p>on page:</p>
  
  <pre><code>echo rh_widget('Search');
  </code></pre>
  
  <p>the function (on functions page):</p>
  
  <pre><code>function rh_widget($str) {
  global $db, $table_prefix;
  $newwidget = 'rh_'.strtolower($str);
      if(class_exists($newwidget)):
      $rh_wid = new $newwidget(); 
      echo $rh_wid-&gt;rh_widget;
      endif;
  </code></pre>
  
  <p>}</p>
  
  <p>Then a Parent &amp; child class (on classes page) such as:</p>
  
  <pre><code>class widget {
  public $str;
  function __construct() {
  $this-&gt;before_widget .= '&lt;ul class="rh_widget"&gt;';
  $this-&gt;before_title .= '&lt;li&gt;&lt;h3&gt;'.$str.'';
  $this-&gt;after_title .= '&lt;/h3&gt;&lt;ul&gt;';
  $this-&gt;after_widget .= '&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;';
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>class rh_search extends widget {
  public function __construct() {
  parent::__construct();
  global $db, $table_prefix;
      $this-&gt;rh_widget .= $this-&gt;before_widget;
      $this-&gt;rh_widget .= $this-&gt;before_title.' '.$this-&gt;after_title; 
      $this-&gt;rh_widget .= '&lt;li&gt;Content etc. in here&lt;/li&gt;';
      $this-&gt;rh_widget .= $this-&gt;after_widget;    
  </code></pre>
  
  <p>}
  }</p>
  
  <p>What I cannot get to happen is to "pull" $str through from the function call through function to the class.</p>
  
  <p>Any suggestion please.  Thanks</p>