本文整理匯總了PHP中CHttpRequest::getBaseUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP CHttpRequest::getBaseUrl方法的具體用法?PHP CHttpRequest::getBaseUrl怎麽用?PHP CHttpRequest::getBaseUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CHttpRequest
的用法示例。
在下文中一共展示了CHttpRequest::getBaseUrl方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parseUrl
/**
* Parses a URL based on this rule.
* @param CUrlManager $manager the URL manager
* @param CHttpRequest $request the request object
* @param string $pathInfo path info part of the URL (URL suffix is already removed based on {@link CUrlManager::urlSuffix})
* @param string $rawPathInfo path info that contains the potential URL suffix
* @return mixed the route that consists of the controller ID and action ID. False if this rule does not apply.
*/
public function parseUrl($manager, $request, $pathInfo, $rawPathInfo)
{
$len = strlen($request->getBaseUrl());
$page = substr($request->getRequestUri(), $len);
// /index.php?p=123
$tr = array();
if (preg_match_all('/<(\\w+):?(.*?)?>/', $this->pattern, $matches)) {
$tokens = array_combine($matches[1], $matches[2]);
foreach ($tokens as $name => $value) {
if ($value === '') {
$value = '[^\\/]+';
}
$tr["<{$name}>"] = "(?P<{$name}>{$value})";
}
}
$this->pattern = str_replace('?', '\\?', $this->pattern);
$p = trim(rtrim($this->pattern, '*'), '/');
$template = preg_replace('/<(\\w+):?.*?>/', '<$1>', $p);
$this->pattern = '/^\\/' . strtr($template, $tr) . '/';
if (preg_match($this->pattern, $page, $matches)) {
foreach ($_GET as $k => $v) {
unset($_GET[$k]);
}
foreach ($tr as $k => $v) {
$key = substr($k, 1, -1);
if (isset($matches[$key])) {
$_GET[$key] = $matches[$key];
}
}
return $this->route;
}
return false;
}