nebkat
nebkat

Reputation: 8565

CodeIgniter access parent function variable

I have made a script that adds files to a zip (after lots of parsing, etc..) and I have this function:

function _add_file($command)
{
    if (!isset($command["source"]) || !isset($command["dest"])) {
        return;
    }

    if (!get_file_info("files/".$command["source"])) {
        return;
    }

    $zip->addFile("files/".$command["source"], $command["destination"]);
}

It gives an error because $zip is not defined in _add_file. How can I let _add_file access the $zip defined in the function that calls it (without _add_file($command, $zip))?

Upvotes: 0

Views: 155

Answers (1)

bassneck
bassneck

Reputation: 4043

Make it a class variable var $zip and access it with $this->zip

Upvotes: 2

Related Questions