本文整理匯總了PHP中Filter::key方法的典型用法代碼示例。如果您正苦於以下問題:PHP Filter::key方法的具體用法?PHP Filter::key怎麽用?PHP Filter::key使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Filter
的用法示例。
在下文中一共展示了Filter::key方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: session
/**
* Validates $_SESSION[$key] value
*
* @param string $key - key parameter of $_SESSION
* @param mixed $default - return value if key is not found
* @return mixed - string on success ($_SESSION[$key] value) or $default on failure
*/
public static function session($key, $default = null)
{
return Filter::key($key, $_SESSION, $default);
}
示例2: getAttribute
protected function getAttribute($name)
{
return Filter::key($name, $this->attributes);
}
示例3: getControl
public function getControl($name)
{
return Filter::key($name, $this->controls);
}
示例4: regex_key_prc
protected function regex_key_prc($match)
{
return "(?P<{$match[1]}>" . Filter::key($match[1], $this->segments, static::REGEX_SEGMENT) . ')';
}
示例5: accept
/**
* Get accept status.
*
* @return bool
*/
public function accept()
{
if (is_array(parent::current())) {
return false;
}
$this->_key = parent::key();
$this->_current = parent::current();
$matches = [];
$useKey = $this->_flags & self::USE_KEY;
$subject = $useKey ? $this->_key : $this->_current;
$out = false;
switch ($this->_mode) {
case self::MATCH:
$out = 0 !== preg_match($this->_regex, $subject, $matches, $this->_pregFlags);
break;
case self::GET_MATCH:
$this->_current = [];
$out = 0 !== preg_match($this->_regex, $subject, $this->_current, $this->_pregFlags);
break;
case self::ALL_MATCHES:
$this->_current = [];
$out = 0 < preg_match_all($this->_regex, $subject, $this->_current, $this->_pregFlags);
break;
case self::SPLIT:
$this->_current = preg_split($this->_regex, $subject, null, $this->_pregFlags);
$out = is_array($this->_current) && 1 < count($this->_current);
break;
case self::REPLACE:
$numberOfReplacement = 0;
$result = preg_replace($this->_regex, $this->replacement, $subject, -1, $numberOfReplacement);
if (null === $result || 0 === $numberOfReplacement) {
$out = false;
break;
}
if (0 !== $useKey) {
$this->_key = $result;
$out = true;
break;
}
$this->_current = $result;
$out = true;
break;
default:
$out = false;
break;
}
if (0 !== ($this->_flags & self::INVERT_MATCH)) {
return false === $out;
}
return $out;
}