Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problem calling a php method from within itself

Tags:

php

recursion

class styleFinder{

function styleFinder(){

}

function getFilesNFolders($folder){

    $this->folder = $folder ;
    if($this->folder==""){
        $this->folder = '.';
    }
    if ($handle = opendir($this->folder)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                echo "$file<br /> ";
                if(is_dir($file)){

                    echo "<b>" . $file . " is a folder</b><br />&nbsp;&nbsp;&nbsp;with contents ";
                    $this::getFilesNFolders($file);
                   # echo "Found folder";
                }
            }
        }
        closedir($handle);
    }
}

} I wan to print out a complete tree of folders and files, the script is going into the first folders and finding the files, then finding any sub folders, but not subfolders of those (and yes there is some). Any ideas please?

like image 343
Phil Avatar asked Dec 05 '22 01:12

Phil


1 Answers

$this::getFilesNFolders($file);

Should Be

$this->getFilesNFolders($file);
like image 129
FallenAvatar Avatar answered Dec 29 '22 04:12

FallenAvatar