2014-02-20 54 views
0

$ iteration_method ='get_file_object'是什麼意思。這與聲明一個變量並在此處爲其分配一個字符串值是否相同?還是有其他的意義?還是它有其他的意義?在php的oop方法中聲明一個變量

protected function get_file_objects($iteration_method = 'get_file_object') { 
     $upload_dir = $this->get_upload_path(); 
     if (!is_dir($upload_dir)) { 
      return array(); 
     } 
     return array_values(array_filter(array_map(
      array($this, $iteration_method), 
      scandir($upload_dir) 
     ))); 
    } 

回答

0

That`s意思是,如果你不要傳遞給方法任何參數裏面方法將有值「get_file_object」的變量,在其他情況下獲得通過varaible的值,例如:

class test{ 
    public function test($test = 'hello world'){ 
     echo $test; 
    } 
} 

$a = new test(); 
$a->test(); // output hello world 
$a->test('im Michael'); // output im Michael 
+0

Thanks @Ziupex - 這就是我想知道的 – Muhammad