本文整理匯總了PHP中Zend\Uri\Uri::setPort方法的典型用法代碼示例。如果您正苦於以下問題:PHP Uri::setPort方法的具體用法?PHP Uri::setPort怎麽用?PHP Uri::setPort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Uri\Uri
的用法示例。
在下文中一共展示了Uri::setPort方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: clearUri
/**
* Get clear uri.
*
* @static
*
* @param \Zend\Uri\Uri $uri
*
* @return boolean|\Zend\Uri\Uri False if uri is not auhorized
*/
public static function clearUri(Uri $uri)
{
if ($uri->getScheme() !== 'http') {
return false;
}
$uri->setHost('www.vimeo.com');
// clear
$uri->setPort(0);
$uri->setUserInfo('');
$uri->setQuery('');
$uri->setFragment('');
return $uri;
}
示例2: clearUri
/**
* Get clear uri.
*
* @static
*
* @param \Zend\Uri\Uri $uri
*
* @return boolean|\Zend\Uri\Uri False if uri is not auhorized
*/
public static function clearUri(Uri $uri)
{
if ($uri->getScheme() !== 'http') {
return false;
}
$query = $uri->getQueryAsArray();
if (empty($query['v'])) {
return false;
}
$uri->setQuery(array('v' => $query['v']));
$uri->setHost('www.youtube.com');
$uri->setPath('/watch');
// clear
$uri->setPort(0);
$uri->setUserInfo('');
$uri->setFragment('');
return $uri;
}
示例3: invalidRelativeUriObjectProvider
/**
* Data provider for invalid relative URI objects
*
* @return array
*/
public function invalidRelativeUriObjectProvider()
{
// Empty URI is not valid
$obj1 = new Uri();
// Path cannot begin with '//'
$obj2 = new Uri();
$obj2->setPath('//path');
// A object with port
$obj3 = new Uri();
$obj3->setPort(123);
// A object with userInfo
$obj4 = new Uri();
$obj4->setUserInfo('shahar:password');
// A object with scheme
$obj5 = new Uri();
$obj5->setScheme('https');
// A object with host
$obj6 = new Uri();
$obj6->setHost('example.com');
return array(array($obj1), array($obj2), array($obj3), array($obj4), array($obj5), array($obj6));
}
示例4: invalidUriObjectProvider
/**
* Data provider for invalid URI objects
*
* @return array
*/
static public function invalidUriObjectProvider()
{
// Empty URI is not valid
$obj1 = new Uri;
// Path cannot begin with '//' if there is no authority part
$obj2 = new Uri;
$obj2->setPath('//path');
// A port-only URI with no host
$obj3 = new Uri;
$obj3->setPort(123);
// A userinfo-only URI with no host
$obj4 = new Uri;
$obj4->setUserInfo('shahar:password');
return array(
array($obj1),
array($obj2),
array($obj3),
array($obj4)
);
}
示例5: clearUri
/**
* Get clear uri.
*
* @static
*
* @param \Zend\Uri\Uri $uri
*
* @return boolean|\Zend\Uri\Uri False if uri is not auhorized
*/
public static function clearUri(Uri $uri)
{
if ($uri->getScheme() !== 'http') {
return false;
}
$paths = explode('/', $uri->getPath());
$pathsCount = count($paths);
if ($pathsCount < 2) {
return false;
}
$type = $paths[$pathsCount - 2];
if (!in_array($type, self::$typesAuthorized)) {
return false;
}
$uri->setHost('www.deezer.com');
// clear
$uri->setPort(0);
$uri->setUserInfo('');
$uri->setQuery('');
$uri->setFragment('');
return $uri;
}
示例6: setPort
/**
* Set the port part of the URI
*
* @param int $port
* @return \Zend\Uri\Uri
*/
public function setPort($port)
{
$this->uri->setPort($port);
return $this;
}