本文整理匯總了PHP中WebUtils::getCurrentPathURL方法的典型用法代碼示例。如果您正苦於以下問題:PHP WebUtils::getCurrentPathURL方法的具體用法?PHP WebUtils::getCurrentPathURL怎麽用?PHP WebUtils::getCurrentPathURL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WebUtils
的用法示例。
在下文中一共展示了WebUtils::getCurrentPathURL方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setURL
/** ************************************************
* Trims whitespace off the url, then removes the /
* off the right side of the url if it exists.
* Gets the base url and the url with just it's path
* @param:
* @return: null
* @throws:
** ***********************************************/
public function setURL($url)
{
if (is_string($url) && WebUtils::isValidURL($url)) {
$url = rtrim(trim($url), '/');
$this->sURL = $url;
$base = WebUtils::getBaseURL($url);
if ($base == '') {
$base = $url;
}
$this->sBaseURL = $base;
$path = WebUtils::getCurrentPathURL($url);
if ($path == '') {
$path = $url;
}
$this->sCurrentPathURL = $path;
} else {
throw new Exception('AnchorParser.setURL accepts valid URLs only.');
}
}
示例2: traversRelPath
/** ************************************************
* This function tries to travers the given url's path
* but will not work if the realtive path is not traversable
* with the given url.
* @param: $url string; a url
* @param: $relPath string; a relative path
* @return: string; the url after it was traversed by
* relPath. Or false if there was some error/problem
* TODO: Do a better job of adding / in the return string
***************************************************/
public static function traversRelPath($sUrl, $relPath)
{
if (!WebUtils::isValidURL($sUrl)) {
return false;
}
$baseP = WebUtils::getCurrentPathURL($sUrl);
$baseU = WebUtils::getBaseURL($sUrl);
$path = WebUtils::getPathOnly($sUrl);
$path = explode('/', $path);
$relPath = explode('/', $relPath);
//echo '<pre>Path '. var_export($path, true) . '</pre><br/>';
//echo '<pre>rel '. var_export($relPath, true) . '</pre><br/>';
foreach ($relPath as $r) {
if ($r != '.' && $r != '..') {
array_push($path, array_shift($relPath));
continue;
} else {
if ($r == '.') {
array_shift($relPath);
continue;
} else {
if ($r == '..') {
array_shift($relPath);
if (array_pop($path) == null) {
return false;
}
}
}
}
}
return rtrim($baseU . implode('/', $path) . implode('/', $relPath), '/');
}