本文整理汇总了PHP中Zend\Http\PhpEnvironment\Request::getBaseUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getBaseUrl方法的具体用法?PHP Request::getBaseUrl怎么用?PHP Request::getBaseUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Http\PhpEnvironment\Request
的用法示例。
在下文中一共展示了Request::getBaseUrl方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBasePathDetection
/**
* @dataProvider baseUrlAndPathProvider
* @param array $server
* @param string $baseUrl
* @param string $basePath
*/
public function testBasePathDetection(array $server, $baseUrl, $basePath)
{
$_SERVER = $server;
$request = new Request();
$this->assertEquals($baseUrl, $request->getBaseUrl());
$this->assertEquals($basePath, $request->getBasePath());
}
示例2: __construct
public function __construct(Request $request)
{
$uri = substr($request->getRequestUri(), strlen($request->getBaseUrl()));
if ($pos = strpos($uri, '?')) {
$uri = substr($uri, 0, $pos);
}
$this->path = array_filter(explode('/', trim($uri, '/')));
$this->config = (new Routes())->routesMap;
$this->module = $this->getModule();
$this->dir = $this->config[$this->module];
}
示例3: getThemeImage
/**
* Get Theme image
*
* @return string
*/
private function getThemeImage()
{
$homeUrl = $this->request->getBaseUrl();
if (is_file(THEMES_PATH . $this->skin . DS . 'images' . DS . $this->img)) {
// Картинка из текущей темы (если есть)
$file = $homeUrl . '/themes/' . $this->skin . '/images/' . $this->img;
return $this->getLink($file);
} elseif (is_file(ASSETS_PATH . 'template' . DS . 'images' . DS . $this->img)) {
// Если нет в теме, то выдаем картинку по умолчанию
$file = $homeUrl . '/assets/template/images/' . $this->img;
return $this->getLink($file);
}
// Если картинка не найдена
return '';
}
示例4: testBaseurlFallsBackToRootPathIfScriptFilenameIsNotSet
/**
* @group ZF2-480
*/
public function testBaseurlFallsBackToRootPathIfScriptFilenameIsNotSet()
{
$request = new Request();
$server = $request->getServer();
$server->set('SCRIPT_NAME', null);
$server->set('PHP_SELF', null);
$server->set('ORIG_SCRIPT_NAME', null);
$server->set('ORIG_SCRIPT_NAME', null);
$server->set('SCRIPT_FILENAME', null);
$this->assertEquals('', $request->getBaseUrl());
}
示例5: getBaseUrl
/**
* Get base url
*
* @return string
*/
public function getBaseUrl()
{
$url = urldecode(parent::getBaseUrl());
$url = str_replace('\\', '/', $url);
return $url;
}