title: Creating a cURL method in a PHP class
body: <p>I'm trying to create a class that uses cURL to make requests to the Twitter API. I've done some research on object oriented programming in PHP, and I can't quite figure out how this should work. The following code returns NULL:</p>
  
  <pre><code> &lt;?php
  
      class twitter {
  
        public function curlQuery($url) {
        $ch = curl_init();
  
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
  
        $json = curl_exec($ch);
  
        curl_close($ch);
  
        $array = json_decode($json);
        return var_dump($array);
        }
  }
  
  $object1 = new twitter;
  $object1-&gt;url = "http://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&amp;include_rts=true&amp;screen_name=twitterapi&amp;count=2";
  $object1-&gt;curlQuery($object1-&gt;url);
  
   ?&gt;
  </code></pre>
  
  <p>Also, I'm a little unsure when to use <code>$this-&gt;variable</code> vs <code>$variable</code> in a PHP class. Shouldn't all variables mentioned in an class be referenced as <code>$this-&gt;variable</code>? Why would you ever not want to reference the variable of the current object?</p>