Why is my class throwing warnings?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
cesarcesar
Forum Contributor
Posts: 111
Joined: Mon Oct 18, 2004 3:28 pm

Why is my class throwing warnings?

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Don't you have a thread on this class already?

viewtopic.php?p=387194#387194
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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!!!!
User avatar
TheMoose
Forum Contributor
Posts: 351
Joined: Tue May 23, 2006 10:42 am

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

crosspost = locked topic.Image
Locked