本文整理汇总了PHP中Psr\Http\Message\UriInterface::getBasePath方法的典型用法代码示例。如果您正苦于以下问题:PHP UriInterface::getBasePath方法的具体用法?PHP UriInterface::getBasePath怎么用?PHP UriInterface::getBasePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr\Http\Message\UriInterface
的用法示例。
在下文中一共展示了UriInterface::getBasePath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRequestTarget
/**
* Retrieves the message's request target.
*
* Retrieves the message's request-target either as it will appear (for
* clients), as it appeared at request (for servers), or as it was
* specified for the instance (see withRequestTarget()).
*
* In most cases, this will be the origin-form of the composed URI,
* unless a value was provided to the concrete implementation (see
* withRequestTarget() below).
*
* If no URI is available, and no request-target has been specifically
* provided, this method MUST return the string "/".
*
* @return string
*/
public function getRequestTarget()
{
if ($this->requestTarget) {
return $this->requestTarget;
}
if ($this->uri === null) {
return '/';
}
$path = $this->uri->getBasePath();
$path .= $this->uri->getPath();
$query = $this->uri->getQuery();
if ($query) {
$path .= '?' . $query;
}
$this->requestTarget = $path;
return $this->requestTarget;
}
示例2: getRequestTarget
/**
* Retrieves the message's request target.
*
* Retrieves the message's request-target either as it will appear (for
* clients), as it appeared at request (for servers), or as it was
* specified for the instance (see withRequestTarget()).
*
* In most cases, this will be the origin-form of the composed URI,
* unless a value was provided to the concrete implementation (see
* withRequestTarget() below).
*
* If no URI is available, and no request-target has been specifically
* provided, this method MUST return the string "/".
*
* @return string
*/
public function getRequestTarget()
{
if ($this->requestTarget) {
return $this->requestTarget;
}
if ($this->uri === null) {
return '/';
}
$basePath = method_exists($this->uri, 'getBasePath') ? $this->uri->getBasePath() : '';
$path = $this->uri->getPath();
$path = $basePath . '/' . ltrim($path, '/');
$query = $this->uri->getQuery();
if ($query) {
$path .= '?' . $query;
}
$this->requestTarget = $path;
return $this->requestTarget;
}
示例3: basePath
public function basePath()
{
return $this->uri->getBasePath();
}
示例4: extractPath
/**
* @param UriInterface $uri
*
* @return string
*/
private function extractPath(UriInterface $uri)
{
// Slim3 compatibility
if ($uri instanceof Uri) {
$basePath = $uri->getBasePath();
if (!empty($basePath)) {
return $basePath;
}
}
return $uri->getPath();
}