本文整理匯總了PHP中MOXMAN_Util_PathUtils::sitePaths方法的典型用法代碼示例。如果您正苦於以下問題:PHP MOXMAN_Util_PathUtils::sitePaths方法的具體用法?PHP MOXMAN_Util_PathUtils::sitePaths怎麽用?PHP MOXMAN_Util_PathUtils::sitePaths使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MOXMAN_Util_PathUtils
的用法示例。
在下文中一共展示了MOXMAN_Util_PathUtils::sitePaths方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getSitePaths
/**
* getSitePaths
*
* @param string $file Site absolute path.
* @param string $script URL path.
*
* @return Array With wwwroot and prefix.
*/
public static function getSitePaths($file = "", $script = "")
{
if (self::$sitePaths && !defined('PHPUNIT')) {
return self::$sitePaths;
}
if (!$file && defined("MOXMAN_API_FILE")) {
$file = MOXMAN_API_FILE;
}
$file = $file ? $file : $_SERVER["SCRIPT_FILENAME"];
$script = $script ? $script : $_SERVER["SCRIPT_NAME"];
$file = explode("/", self::toUnixPath($file));
$script = explode("/", self::toUnixPath($script));
$u = count($file) - 1;
for ($i = count($script) - 1; $i >= 0; $i--) {
$val = $file[$u--];
if ($val != $script[$i]) {
$u++;
// To include last chunk
break;
}
}
$wwwroot = implode("/", array_slice($file, 0, $u + 1));
$prefix = implode("/", array_slice($script, 0, $i + 1));
self::$sitePaths = array("wwwroot" => $wwwroot, "prefix" => $prefix);
return self::$sitePaths;
}
示例2: getSitePaths
/**
* getSitePaths
*
* @param string $file Site absolute path /var/www/dir/file
* @param string $script URL path. /dir/file
* @return Array With wwwroot and prefix.
*/
public static function getSitePaths($file = "", $script = "")
{
// @codeCoverageIgnoreStart
if (self::$sitePaths && !defined('PHPUNIT')) {
return self::$sitePaths;
}
// @codeCoverageIgnoreEnd
// Check if we have a defined MOXMAN_API_FILE this might not be the case
// if MOXMAN.php is loaded directly we then need to fallback to SCRIPT_FILENAME
//if (!$file && defined("MOXMAN_API_FILE")) {
// $file = MOXMAN_API_FILE;
//}
$file = $file ? $file : MOXMAN_ROOT;
$script = $script ? $script : dirname($_SERVER["SCRIPT_NAME"]);
$file = explode("/", self::toUnixPath($file));
$script = explode("/", self::toUnixPath($script));
$u = count($file) - 1;
for ($i = count($script) - 1; $i >= 0; $i--) {
$val = $file[$u--];
if (strtolower($val) != strtolower($script[$i])) {
$u++;
// To include last chunk
break;
}
}
$wwwroot = implode("/", array_slice($file, 0, $u + 1));
$prefix = implode("/", array_slice($script, 0, $i + 1));
self::$sitePaths = array("wwwroot" => $wwwroot, "prefix" => $prefix);
return self::$sitePaths;
}