Page 1 of 1

Why is my class throwing warnings?

Posted: Mon Jun 04, 2007 11:13 pm
by cesarcesar
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Why is this code throwing the following errors? Thanks.

Code: Select all

<?
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


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Jun 04, 2007 11:21 pm
by feyd
Don't you have a thread on this class already?

viewtopic.php?p=387194#387194

Posted: Tue Jun 05, 2007 10:51 am
by RobertGonzalez
Yes, and that same question was answered in that other thread several times.

YOU NEED TO SUPPLY A VALUE FOR THE REQUIRED PARAMETER!!!!

Posted: Tue Jun 05, 2007 11:07 am
by TheMoose
viewtopic.php?p=387194#387245

Everah suggested you try this, but it appears as though you haven't. Try it before asking why it doesn't work to help rule out what does and doesn't work.

Posted: Tue Jun 05, 2007 2:42 pm
by Weirdan
crosspost = locked topic.Image