我有一个名为 website_check 的函数
function website_check($url){
if ($url !=""){
if (preg_match("#^https?://.+#", $url) and fopen($url,"r")){
return TRUE;
}else{
$this->form_validation->set_message('Website url', 'The %s field is invalid');
return FALSE;
}
}else{
$this->form_validation->set_message('Website url', 'The %s field is required');
return FALSE;
}
}
我将此功能用作自定义代码点火器表单验证功能
$this->form_validation->set_rules('website', 'Website', 'callback_website_check');
我在每个控制器中都使用这个函数,所以我想将此函数添加到 codeigniters 表单验证类中并用作默认验证函数。是否可以将您的函数添加到 codeigniters 表单验证类,如果可以做到的话?