本文整理汇总了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;
}