Recursive call in a php app

Given the following code why isn't the addDir functional able to call itself.

08-Sep-2015 16:18:46 America/New_York] PHP Fatal error:  Call to undefined method ZipArchive::addDir() in C:\inetpub\wwwroot\try.php on line 11


function addDir($path, $zipit ,$parent_dir = '') {
        if($parent_dir != ''){
            $zipit->addEmptyDir($parent_dir);
            $parent_dir .= '/';
             }
        $nodes = glob($path . '/*');
        foreach ($nodes as $node) {
            if (is_dir($node)) {
              $result=  addDir($node, $zipit,$parent_dir.basename($node));
            }
            else if (is_file($node))  {
                $zipit->addFile($node, $parent_dir.basename($node));
            
        }
    } 
return true;
}
// define some basics
$rootPath = 'c:/php/';

$archiveName = "zipfile.zip";
// initialize the ZIP archive

$zip = new ZipArchive;
$zip->open('c:/smtp/ziptest.zip', ZIPARCHIVE::OVERWRITE );
// close the zip file
$result = addDir("c:/php",$zip);
if (!$zip->close()) {
	echo '<p>There was a problem writing the ZIP archive.</p>';
} else {
	echo '<p>Successfully created the ZIP Archive!</p>';
}

Open in new window

LVL 1
HalCHubAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Please check the line numbers - line 11 does not contain a function call.  thanks.
Ahmed MerghaniSoftware EngineerCommented:
I checked it and it worked!!

Is there any else code you did not display here??

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HalCHubAuthor Commented:
the lines are off because I removed the <?php
Ray PaseurCommented:
OK, please post the script just the way it is in real life - we need to be able to see the same script and same error messages you see.  thanks.
HalCHubAuthor Commented:
I forgot to install ziparchive :(
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.