本文整理匯總了PHP中Inspekt::isHostname方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inspekt::isHostname方法的具體用法?PHP Inspekt::isHostname怎麽用?PHP Inspekt::isHostname使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inspekt
的用法示例。
在下文中一共展示了Inspekt::isHostname方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testIsHostname
/**
*
*/
public function testIsHostname()
{
$input = '192.168.1.1';
$this->assertTrue(Inspekt::isHostname($input));
}
示例2: testHostname
/**
* Returns value if it is a valid hostname, FALSE otherwise.
* Depending upon the value of $allow, Internet domain names, IP
* addresses, and/or local network names are considered valid.
* The default is HOST_ALLOW_ALL, which considers all of the
* above to be valid.
*
* @param mixed $key
* @param integer $allow bitfield for HOST_ALLOW_DNS, HOST_ALLOW_IP, HOST_ALLOW_LOCAL
* @return mixed
*
* @tag validator
*/
function testHostname($key, $allow = ISPK_HOST_ALLOW_ALL)
{
if (!$this->keyExists($key)) {
return false;
}
if (Inspekt::isHostname($this->_getValue($key), $allow)) {
return $this->_getValue($key);
}
return FALSE;
}
示例3: testHostname
/**
* Returns value if it is a valid hostname, FALSE otherwise.
* Depending upon the value of $allow, Internet domain names, IP
* addresses, and/or local network names are considered valid.
* The default is HOST_ALLOW_ALL, which considers all of the
* above to be valid.
*
* @param mixed $key
* @param int $allow bitfield for HOST_ALLOW_DNS, HOST_ALLOW_IP, HOST_ALLOW_LOCAL
* @return mixed
* @throws Exception
* @tag validator
*/
public function testHostname($key, $allow = Inspekt::ISPK_HOST_ALLOW_ALL)
{
$value = $this->getValueOrNull($key);
if (!is_null($value) && Inspekt::isHostname($value, $allow)) {
return $value;
}
return false;
}