<?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>'; ?>
<?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>'; ?>
$list_df print to browser a null massiv. I want to print browser a full massiv (include names of files and directory)... Please help me.. I search a error?
p.s.: Hello from Russia :-)
You never define the $url property... perhaps this:
$url = getcwd(); //current directory
should have been this:
$this->url = getcwd(); //current directory
?
bradgrafelman, thank you ..)