本文整理匯總了PHP中yii\helpers\Url::ensureScheme方法的典型用法代碼示例。如果您正苦於以下問題:PHP Url::ensureScheme方法的具體用法?PHP Url::ensureScheme怎麽用?PHP Url::ensureScheme使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yii\helpers\Url
的用法示例。
在下文中一共展示了Url::ensureScheme方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createAbsoluteUrl
/**
* Creates an absolute URL using the given route and query parameters.
*
* This method prepends the URL created by [[createUrl()]] with the [[hostInfo]].
*
* Note that unlike [[\yii\helpers\Url::toRoute()]], this method always treats the given route
* as an absolute route.
*
* @param string|array $params use a string to represent a route (e.g. `site/index`),
* or an array to represent a route with query parameters (e.g. `['site/index', 'param1' => 'value1']`).
* @param string|null $scheme the scheme to use for the URL (either `http`, `https` or empty string
* for protocol-relative URL).
* If not specified the scheme of the current request will be used.
* @return string the created URL
* @see createUrl()
*/
public function createAbsoluteUrl($params, $scheme = null)
{
$params = (array) $params;
$url = $this->createUrl($params);
if (strpos($url, '://') === false) {
$url = $this->getHostInfo() . $url;
}
return Url::ensureScheme($url, $scheme);
}