Jump to content

Why is my class throwing warnings?


cesarcesar

Recommended Posts

Why is this code throwing the following errors? Thanks.

 

<?
class DirTree {

    /**
     * Get a tree of folders and files from a spec dir
     * @returns An ArrayCollection of Tree
     */
function DirTree($dir_tree) {
	$_tree = $this->parse_dir($dir_tree);
	return $_tree;
}

    /**
     * Get a tree of folders and files from a spec dir
     * @returns An Array of Tree
     */
function parse_dir($folder) {

	$dir                = @opendir($folder);
	$filecount          = 0;
	$foldercount		= 0;
	$tree				= array();
	$limb				= array();
	$cnt				= 0;

	while(false != ($item = @readdir($dir))) {

		if($item == "." || $item == "..") continue;

		if(is_dir("$folder/$item")){

			$tmpTree = new DirTree();

			$limb['sub_folder'][]['folder_name'] = $item;
			$limb['sub_folder'][] = $tmpTree->parse_dir("$folder/$item");

			$foldercount++;
			$limb['folders'][] = $foldercount;

			$filecount++;
			$limb['files'][] = $filecount;
			//continue;

		}else{

			$limb['file_name'][] = $item;

		}
	}

	$tree[] = $limb;
	$cnt++;
	return $tree;

}
}

$class = new DirTree();

/* view array  */
echo "<pre>";
print_r($class->DirTree("../../core/amf/app"));
echo "</pre>*****************************************************************";
?>

 

Warning: Missing argument 1 for DirTree::DirTree() in C:\apache2triad\htdocs\flashservices_v1.9\services\folder_tree\dir_tree2.php on line 8

 

Notice: Undefined variable: dir_tree in C:\apache2triad\htdocs\flashservices_v1.9\services\folder_tree\dir_tree2.php on line 9

 

Warning: Missing argument 1 for DirTree::DirTree() in C:\apache2triad\htdocs\flashservices_v1.9\services\folder_tree\dir_tree2.php on line 8

 

Notice: Undefined variable: dir_tree in C:\apache2triad\htdocs\flashservices_v1.9\services\folder_tree\dir_tree2.php on line 9

 

Warning: Missing argument 1 for DirTree::DirTree() in C:\apache2triad\htdocs\flashservices_v1.9\services\folder_tree\dir_tree2.php on line 8

 

Notice: Undefined variable: dir_tree in C:\apache2triad\htdocs\flashservices_v1.9\services\folder_tree\dir_tree2.php on line 9

 

Warning: Missing argument 1 for DirTree::DirTree() in C:\apache2triad\htdocs\flashservices_v1.9\services\folder_tree\dir_tree2.php on line 8

 

Notice: Undefined variable: dir_tree in C:\apache2triad\htdocs\flashservices_v1.9\services\folder_tree\dir_tree2.php on line 9

 

Warning: Missing argument 1 for DirTree::DirTree() in C:\apache2triad\htdocs\flashservices_v1.9\services\folder_tree\dir_tree2.php on line 8

 

Notice: Undefined variable: dir_tree in C:\apache2triad\htdocs\flashservices_v1.9\services\folder_tree\dir_tree2.php on line 9

Link to comment
https://forums.phpfreaks.com/topic/54230-why-is-my-class-throwing-warnings/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.