本文整理汇总了PHP中Lobby::url方法的典型用法代码示例。如果您正苦于以下问题:PHP Lobby::url方法的具体用法?PHP Lobby::url怎么用?PHP Lobby::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lobby
的用法示例。
在下文中一共展示了Lobby::url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public static function init()
{
/**
* Callback on fatal errors
*/
register_shutdown_function(function () {
return \Lobby::fatalErrorHandler();
});
self::sysinfo();
self::config();
if (isset(self::$config['lobby_url'])) {
$url_parts = parse_url(self::$config['lobby_url']);
self::$host_name = $url_parts['host'];
self::$url = self::$config['lobby_url'];
} else {
$base_dir = L_DIR;
$doc_root = preg_replace("!{$_SERVER['SCRIPT_NAME']}\$!", '', $_SERVER['SCRIPT_FILENAME']);
$base_url = preg_replace("!^{$doc_root}!", '', $base_dir);
# ex: '' or '/mywebsite'
$protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
$port = $_SERVER['SERVER_PORT'];
$disp_port = $protocol == 'http' && $port == 80 || $protocol == 'https' && $port == 443 ? '' : ":{$port}";
$domain = $_SERVER['SERVER_NAME'];
self::$url = "{$protocol}://{$domain}{$disp_port}{$base_url}";
self::$host_name = $domain;
}
}
示例2: getURL
/**
* Get/Make the Lobby base URL
*/
public static function getURL()
{
if (self::$url !== null) {
return self::$url;
}
if (self::$cli) {
return null;
}
if (isset(self::$config['lobby_url'])) {
$url_parts = parse_url(self::$config['lobby_url']);
self::$hostname = $url_parts['host'];
self::$url = self::$config['lobby_url'];
} else {
$docDir = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
$subdir = str_replace($docDir, '', L_DIR);
$urladdr = $_SERVER['HTTP_HOST'] . $subdir;
$urladdr = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://" . $urladdr;
self::$url = rtrim($urladdr, "/");
self::$host = $_SERVER['SERVER_NAME'] . (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] != "80" ? ":{$_SERVER['SERVER_PORT']}" : "");
self::$hostname = $_SERVER['SERVER_NAME'];
}
return self::$url;
}