SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why is my class throwing warnings?

    Why is this code throwing the following errors? Thanks.

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

  2. #2
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    The warning tells you why its throwing a warning.

    Warning: Missing argument 1

    This should be all the clue you need..

  3. #3
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    obviously if im asking for help i've tried a few things as per the warning. i am new to classes please assist if you can.

  4. #4
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey your class constructor has one argument
    PHP Code:
    function DirTree($dir_tree) {


    And you have not passed any argument here on call:
    PHP Code:
    $class = new DirTree(); 
    So try to pass one parameter:
    PHP Code:
    $paramter "../../core/amf/app";
    $class = new DirTree($paramter); 
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •