本文整理汇总了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;
}