本文整理匯總了PHP中Zend\Uri\Uri::validateHost方法的典型用法代碼示例。如果您正苦於以下問題:PHP Uri::validateHost方法的具體用法?PHP Uri::validateHost怎麽用?PHP Uri::validateHost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Uri\Uri
的用法示例。
在下文中一共展示了Uri::validateHost方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: fromString
public static function fromString($headerLine)
{
$header = new static();
list($name, $value) = explode(': ', $headerLine, 2);
// check to ensure proper header type for this factory
if (strtolower($name) !== 'location') {
throw new Exception\InvalidArgumentException('Invalid header line for Location string: "' . $name . '"');
}
if (!Uri::validateHost($value)) {
throw new Exception\InvalidArgumentException('Invalid URI value for Location: "' . $value . '"');
}
// @todo implementation details
$header->value = $value;
return $header;
}
示例2: testValidateHostInvalid
/**
* Check that invalid hosts are invalid according to validateHost()
*
* @param string $host
* @dataProvider invalidHostProvider
*/
public function testValidateHostInvalid($host)
{
$this->assertFalse(Uri::validateHost($host));
}
示例3: setUri
/**
* Set the URI/URL for this request, this can be a string or an instance of Zend\Uri\Http
*
* @throws Exception\InvalidArgumentException
* @param string|HttpUri $uri
* @return Request
*/
public function setUri($uri)
{
if (is_string($uri)) {
if (!\Zend\Uri\Uri::validateHost($uri)) {
throw new Exception\InvalidArgumentException('Invalid URI passed as string');
}
} elseif (!$uri instanceof \Zend\Uri\Http) {
throw new Exception\InvalidArgumentException('URI must be an instance of Zend\\Uri\\Http or a string');
}
$this->uri = $uri;
return $this;
}