本文整理匯總了PHP中Webapp::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP Webapp::init方法的具體用法?PHP Webapp::init怎麽用?PHP Webapp::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Webapp
的用法示例。
在下文中一共展示了Webapp::init方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: str_replace
self::$DOC_ROOT = str_replace(self::$SCRIPT_NAME, '', self::$SCRIPT_FILENAME);
// ex: /var/www
self::$BASE_URL = str_replace(self::$DOC_ROOT, '', self::$BASE_DIR);
// ex: '' or '/mywebsite'
self::$PROTOCOL = empty($_SERVER['HTTPS']) ? 'http' : 'https';
self::$PORT = $_SERVER['SERVER_PORT'];
self::$DISP_PORT = self::$PROTOCOL == 'http' && self::$PORT == 80 || self::$PROTOCOL == 'https' && self::$PORT == 443 ? '' : ":" . self::$PORT;
self::$DOMAIN = $_SERVER['SERVER_NAME'];
self::$FULL_URL = self::$PROTOCOL . "://" . self::$DOMAIN . self::$DISP_PORT . self::$BASE_URL;
$subdomains = explode(".", $_SERVER['HTTP_HOST']);
self::$SUBDOMAIN = array_shift($subdomains);
if (array_key_exists('REQUEST_SCHEME', $_SERVER)) {
self::$REMOTE_HOST = $_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER["SCRIPT_NAME"]);
} else {
self::$REMOTE_HOST = "http://" . $_SERVER["HTTP_HOST"];
}
self::$REMOTE_HOST = str_replace('\\', "/", self::$REMOTE_HOST);
$pathinfo = pathinfo($_SERVER["REQUEST_URI"]);
$parsedInfo = parse_url($_SERVER["REQUEST_URI"]);
//print_r($pathinfo);
//print_r($parsedInfo);
self::$REQUEST_PATHNAME = $parsedInfo['path'];
self::$REQUEST_DIRNAME = $pathinfo['dirname'];
self::$REQUEST_QUERY = isset($parsedInfo['query']) ? $parsedInfo['query'] : "";
self::$REQUEST_FILE_EXT = isset($pathinfo['extension']) ? $pathinfo['extension'] : "";
self::$REQUEST_FILENAME = str_replace("?" . self::$REQUEST_QUERY, "", $pathinfo['basename']);
self::$REQUEST_FILE_EXT = str_replace("?" . self::$REQUEST_QUERY, "", self::$REQUEST_FILE_EXT);
}
}
Webapp::init();