Я работаю своим путем, хотя David Powers OO Solutions и вам нужна помощь в понимании одного из методов в его классе Pos_Validator.Нужна помощь в понимании removeTagsFromArray (David Powers)
Имя методы подразумевает, что он обрабатывает массивы, однако, первые вызовы аргумента в одно имени поля? Остальные аргументы необязательны. Что мне здесь не хватает?
/**
* Sanitizes array by removing completely all tags (including PHP and HTML).
*
* The second and third optional arguments determine whether the ampersand
* and quotes are converted to numerical entitites. By default, ampersands are
* not converted, but both double and single quotes are replaced by numerical
* entities.
*
* Arguments four to seven determine whether characters with an ASCII value less than 32 or
* greater than 127 are encoded or stripped. By default, they are left untouched.
*
* @param string $fieldName Name of submitted value to be checked.
* @param boolean $encodeAmp Optional; converts & to & if set to true; defaults to false.
* @param boolean $preserveQuotes Optional; preserves double and single quotes if true; defaults to false.
* @param boolean $encodeLow Optional; converts ASCII values below 32 to entities; defaults to false.
* @param boolean $encodeHigh Optional; converts ASCII values above 127 to entities; defaults to false.
* @param boolean $stripLow Optional; strips ASCII values below 32; defaults to false.
* @param boolean $stripHigh Optional; strips ASCII values above 127; defaults to false.
*/
public function removeTagsFromArray($fieldName, $encodeAmp = false, $preserveQuotes = false, $encodeLow = false, $encodeHigh = false, $stripLow = false, $stripHigh = false)
{
// Check that another validation test has not been applied to the same input
$this->checkDuplicateFilter($fieldName);
// Set the filter options
$this->_filterArgs[$fieldName]['filter'] = FILTER_SANITIZE_STRING;
// Multiple flags are set using the "binary or" operator
$this->_filterArgs[$fieldName]['flags'] = FILTER_REQUIRE_ARRAY;
if ($encodeAmp) {
$this->_filterArgs[$fieldName]['flags'] |= FILTER_FLAG_ENCODE_AMP;
}
if ($preserveQuotes) {
$this->_filterArgs[$fieldName]['flags'] |= FILTER_FLAG_NO_ENCODE_QUOTES;
}
if ($encodeLow) {
$this->_filterArgs[$fieldName]['flags'] |= FILTER_FLAG_ENCODE_LOW;
}
if ($encodeHigh) {
$this->_filterArgs[$fieldName]['flags'] |= FILTER_FLAG_ENCODE_HIGH;
}
if ($stripLow) {
$this->_filterArgs[$fieldName]['flags'] |= FILTER_FLAG_STRIP_LOW;
}
if ($stripHigh) {
$this->_filterArgs[$fieldName]['flags'] |= FILTER_FLAG_STRIP_HIGH;
}
}
Без дополнительного контекста (не знакомы с ресурсом) Не могу сказать, почему метод называется 'removeTagsFromArray()'. Но в соответствии с его определением и блоком doc он определенно работает с строкой, устанавливая свойства проверки для имени имени строки в '$ this -> _ filterArgs()'. –
Спасибо @Michael. – jhcorsair