PHP Class Function returning a variable in a new file with-in a new function
<p>I'm in need of some help with this insane issue i'm having</p>

<p>I have a class i made that i'm using Curl to obtain data from a URL and with that information $_GET's each variable a value.</p>

<p>So i have the class and i'm using a new file to get the $name of the item posted in a new function but every-time i put the phrased variable in the new function i get NULL here is my class in-short</p>

<pre><code>class AppStore {

  public $name;


public function getData() {
       $requestUrl = self::APPSTORE_LOOKUP_URL . $this-&gt;appIdentity;

       $ch = curl_init($requestUrl);
                curl_setopt($ch, CURLOPT_URL, $requestUrl);
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
                curl_setopt($ch, CURLOPT_REFERER, "");
                curl_setopt($ch, CURLOPT_COOKIESESSION, true);
                curl_setopt($ch, CURLOPT_USERAGENT, $this-&gt;iTunesUserAgent);
                curl_setopt($ch, CURLOPT_ENCODING, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_FAILONERROR, true);
                curl_setopt($ch, CURLOPT_TIMEOUT, 30);
                $response = curl_exec($ch);
                $errno = curl_errno($ch);
                curl_close($ch);


        $parsedResponse = json_decode($response, true);
        if ($parsedResponse['resultCount'] == 1)
         {
            $parsedResponse = $parsedResponse['results'][0];

            $this-&gt;name = $parsedResponse['trackName'];
             require_once('func.ini.php'); // new function to save images etc
        } else {
            throw new AppStoreService_Exception("mInvalid data returned from the AppStore Web Service. Check your app ID, and verify that the Appstore is currently up.");
        }

} 

}

// This is the func.ini.php code
echo $parsedResponse['trackName']; // Works here output equals a Name like Baraka etc
function save_image($img){

    $dirs = "data/Apps/".$name; // Gets the name of the ID in the appIdentity so we can use CURL to download images and move the images to new folder else it'll fail and won't move 
    $path = $dirs."ScreenShots";
    $fullp = basename($img);
    $fullpath = "$path/$fullp";
    $something = $dirs.'ScreenShots'

    var_dump($parsedResponse['trackName']); // Null same if i echo it i get a white page etc

    /* Sample Code 
    $ch = curl_init ($img);
    curl_setopt($ch, CURLOPT_URL,$img);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
    */

}
</code></pre>

<p>Basically if you can see if I try to add my class's variable to get the Name of the appIdentity in the new function, save_image it'll be null and i'm not sure how I'll be able to return the $this->name ($parsedResponse['trackName']) to be global for all use in new functions etc since my class is using the public getData() then the $this->name (getData()->name)</p>

<p>this only works out side any functions so if there is a function, the variable set to name will only have value above the function(s) i hope this is understandable.</p>

<p>Not sure if i need to make a return in the $this->name or what because i tried making a new public function in the class below the getName() and that comes out null as well thus i can't set public variables in a = statement because it'll catch(e) from try{} asking it expects a T_FUNCTION than T_VARIABLE i.e public $name = $name; // error public $name = 'Test'; // works '{$name}' don't work</p>

<pre><code>class Test {

public $test = 'Help me out please!';
  function GetMe() {
      echo $this-&gt;test;
  } 

}

$open = new Test;
echo $open-&gt;GetMe(); // Outputs "Help me out please"
</code></pre>

<p>/* i can't do that with a variable though :( i.g $this->name / $parsedResponse['trackName'] */</p>

<p>If anyone can help me out I'd be much appreciated </p>
