我有以下内容,但我不知道如何将 $type 变量传递给第二个 checkUkPhone 函数或弄清楚如何引用它。有任何想法吗?
public function isValidUkPhone($fieldName, $type) {
//Set the filter options
$this -> _filterArgs[$fieldName] = array('filter' => FILTER_CALLBACK, 'options' => array($this, 'checkUkPhone'));
}
public function checkUkPhone($type) {
$this -> _errors[$fieldName] = $FieldName.':Phone must begin with 07';
}
// Apply the validation tests using filter_input_array()
$this->_filtered = filter_var_array($data, $this->_filterArgs);
foreach ($this->_filtered as $key => $value) {
// Skip items that used the isBool() method or that are either missing or not required
if (in_array($key, $this->_booleans) || in_array($key, $this->_missing) || !in_array($key, $this->_required)) {
if (in_array($key, $this->_missing)){
$this->_errors[$key] = $key . ':Required';
}
continue;
} elseif ($value === false) {
// If the filtered value is a boolean false, it failed validation,
// so add it to the $errors array
$this->_errors[$key] = $key . ':Invalid data supplied';
}
}
// Return the validated input as an array
return $this->_filtered;