仅在另一个目录中读取目录

I'm attempting to list all the folder names within a selected directory. Currently the only output is "." and ".." but my code is currently designed to remove them. Other than that there are directories within my test folder yet my output is just a blank page.

Here is the code:

class diring {

    private $target = '/Users/Matthew/Documents/MDCMS/public_html/templates';

    private $dirs = array();

    private $err = array();

    function readdirs() {

        if (is_dir($this->target)) {
            if ($handle = opendir($this->target)) {
            while (false !== ($item = readdir($handle))) {
            if (is_dir($item) && $item != "." && $item != "..") {
              echo $item;
            }
            }
            closedir($handle);
            }  
        } else {
            $this->err[] = 'The directory you are trying to access does\'nt exist. ';
            $this->errs();
        }

    }

    function errs() {

        $errors = $this->err;
        if (!empty($errors)) {
            foreach ($errors as $error) {
                echo $error;
            }
        }

    }




}

Anybody know what i'm missing, looking through documentation this should be all i need to do to output the folder names.

Thanks

Much easier:

if(is_dir($this->target)) {
    foreach(glob($this->target . '/*', GLOB_ONLYDIR) as $dir) {
        echo basename($dir);
    }
}

Another way if you want to maintain an array of just the basenames:

if(is_dir($this->target)) {
    $dirs = array_map('basename', glob($this->target . '/*', GLOB_ONLYDIR));
    foreach($dirs as $dir) {
        echo $dir;
    }
}