title: Defining a variable in a class and using it in functions
body: <p>I am trying to learn PHP classes so I can begin coding more OOP projects. To help me learn I am building a class that uses the Rapidshare API. Here's my class:</p>
  
  <pre><code>&lt;?php
  
  class RS
  {
      public $baseUrl = 'http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=';
  
      function apiCall($params)
      {
          echo $baseUrl;
      }
  }
  
  ?&gt;
  </code></pre>
  
  <p><code>$params</code> will contain a set of key pair values, like this:</p>
  
  <pre><code>$params = array(
      'sub'   =&gt;  'listfiles_v1',
      'type'  =&gt;  'prem',
      'login' =&gt;  '746625',
      'password'  =&gt;  'not_my_real_pass',
      'realfolder'    =&gt; '0',
      'fields'    =&gt; 'filename,downloads,size',
      );
  </code></pre>
  
  <p>Which will later be appended to <code>$baseUrl</code> to make the final request URL, but I can't get $baseUrl to appear in my <code>apiCall()</code> method. I have tried the following:</p>
  
  <pre><code>var $baseUrl = 'http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=';
  
  $baseUrl = 'http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=';
  
  private $baseUrl = 'http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=';
  </code></pre>
  
  <p>And even tried <code>$this-&gt;baseUrl = $baseUrl;</code> in my <code>apiCall()</code> methid, I don't know what the hell I was thinking there though lol.</p>
  
  <p>Any help is appreciated thanks :)</p>