本帖最后由 mingfish 于 2010-05-18 09:47:18 编辑

解决方案 »

  1.   


    class Needed_Cssjs{
            public $name ;        //值应该是$needed_cssjs_array[i][0]
            function copy(){
                if(!file_exists('test/'.$this->name)){
                    copy($this->name,'test/'.$this->name);
                }
            }
        }$hello=new Needed_Cssjs;
    $hello->name=$needed_cssjs_array[i][0];
    $hello->copy();
      

  2.   

    我很好奇你是怎么post一个三维数组过来的……,这个不管,然后你程序设计描述上:如果test下没有某文件,那么就复制过来?从哪里复制? 我随手写的temp目录,大体class如下,自行修改下吧。
    <?php
        // $needed_cssjs_array 其实是post过来的。
        $needed_cssjs_array= array();
        $needed_cssjs_array[0]= array("main.css","css/main.css");
        $needed_cssjs_array[1]= array("menu.css","css/menu_bg/menu.css");
        $needed_cssjs_array[2]= array("tab.css","css/tab_bg/tab.css");
        $needed_cssjs_array[3]= array("jquery.js","js/jquery.js");
        
        //判断 test文件夹下是否有 $needed_cssjs_array 中的文件
        // 比如 $needed_cssjs_array[0][1]
        //如果没有就复制到test文件夹下。
        //请问用定义对象属性方法的方法怎么设计?
        
        class Needed_Cssjs{
            public $tmpFile ;        //值应该是$needed_cssjs_array[i][0]
            
            public function doSetFile($strFile){ if ($strFile){ $this->tmpFile = $strFile } }
            public function doParse(){
             if (!$strFile){ return; }
             if (!is_file('/test/' . $strFile)){ copy('/temp/' . $strFile , '/test/' . $strFile ); }
            }
        }
        
        $hello=new Needed_Cssjs;
        $hello->doParse();
        
    ?>