本文整理匯總了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();
}