本文整理匯總了PHP中URI::getPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP URI::getPath方法的具體用法?PHP URI::getPath怎麽用?PHP URI::getPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類URI
的用法示例。
在下文中一共展示了URI::getPath方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* @throws SystemException
*/
public function __construct()
{
$this->uri = URI::create();
$path = $this->uri->getPath();
if (strpos($path, E()->getSiteManager()->getCurrentSite()->root) !== false) {
$path = array_values(array_diff(explode('/', substr($path, strlen(E()->getSiteManager()->getCurrentSite()->root))), array('')));
} else {
$path = array();
}
try {
$language = E()->getLanguage();
$this->lang = isset($path[0]) && $language->isValidLangAbbr($path[0]) ? array_shift($path) : '';
} catch (SystemException $e) {
$this->lang = '';
}
$this->path = $path;
}
示例2: mergePaths
/**
* Given 2 paths, will merge them according to rules set out in RFC 2986,
* Section 5.2
*
* @see http://tools.ietf.org/html/rfc3986#section-5.2.3
*
* @param $path1
* @param $path2
*/
protected function mergePaths(URI $base, URI $reference)
{
if (!empty($base->getAuthority()) && empty($base->getPath())) {
return '/' . ltrim($base->getPath(), '/ ');
}
$path = explode('/', $base->getPath());
if (empty($path[0])) {
unset($path[0]);
}
array_pop($path);
array_push($path, $reference->getPath());
return implode('/', $path);
}
示例3: testPathGetsFiltered
/**
* @dataProvider invalidPaths
*/
public function testPathGetsFiltered($path, $expected)
{
$uri = new URI();
$uri->setPath($path);
$this->assertEquals($expected, $uri->getPath());
}