Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   PHP, PERL, MySQL, JavaScript (https://forum.antichat.xyz/forumdisplay.php?f=37)
-   -   ООП. Класс. Сканирование директории. Помогите найти ошибку? (https://forum.antichat.xyz/showthread.php?t=207458)

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: поставьте мне плюсик один, и я вам поставлю.
//а вареньем воротничек не намазать?не?


Время: 03:22