PDA

Просмотр полной версии : ООП. Класс. Сканирование директории. Помогите найти ошибку?


DonKihot
28.05.2010, 19:15
<?php

class File_Manager{

//properties
protected $url; // current url
public $dir; // current directory
protected $df; // current file or directory
public $list_df = array(); // all files and directory in directory

//methods
public function Scan_Directory() // Initialization
{
$url = getcwd(); //current directory
if ($this->dir = opendir($this->url)) //directory is open?
{
while (false !== ($this->df = readdir($this->dir)))
{
if ($this->df != ".." and $this->df != ".") $this->list_df[]= $this->df;
}
closedir($this->dir);
}
}

}

$object = new File_Manager;
$object->Scan_Directory();

$list_df = $object->list_df;

print '<pre>';
print_r($list_df);
print '</pre>';
?>

Выводит массив (в выделенной строке), а массив пуст :-(
в масссиве должны быть файлы и папки, находящиеся в директории.

попугай
28.05.2010, 19:25
прав хватает-то?

Failure
28.05.2010, 19:32
$url = getcwd(); //current directory
заменить на
$this->url = getcwd();

а вообще http://php.net/manual/en/function.scandir.php

DonKihot
28.05.2010, 19:32
прав хватает-то?
да, метод в классе точно работает.
заменить на
спасибо :-)

p.s: поставьте мне плюсик один, и я вам поставлю.
//а вареньем воротничек не намазать?не?