在php oop方法中声明变量
$iteration\u method='get\u file\u object'在这里是什么意思。这与在此处声明变量并为其分配字符串值相同吗?或者它有其他意义吗?或者它有其他意义吗在php oop方法中声明变量,php,oop,variables,methods,Php,Oop,Variables,Methods,$iteration\u method='get\u file\u object'在这里是什么意思。这与在此处声明变量并为其分配字符串值相同吗?或者它有其他意义吗?或者它有其他意义吗 protected function get_file_objects($iteration_method = 'get_file_object') { $upload_dir = $this->get_upload_path(); if (!is_dir($upload_di
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)
)));
}
这意味着,如果您不向方法传递任何参数,那么方法中的变量将具有“get\u file\u object”值,例如,在其他情况下,传递的变量的get值
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
谢谢@Ziupex-这就是我想知道的