Example #1
0
 /**
  * URLを生成.
  * @param[in] $uri     request uri (ex: '/hoge/fuga?foo=bar')
  * @param[in] $scheme  'http' or 'https'
  * @return 完全なURL (ex: http://example.com/hoge/fuga?foo=bar)
  */
 public static function makeUrl($uri, $scheme = null)
 {
     if (self::$url_base === null) {
         $path = '';
         if (preg_match('|^(.*)/[^/]+.php|', $_SERVER['SCRIPT_NAME'], $m)) {
             $path = $m[1];
         }
         if (!$scheme) {
             $scheme = 'http';
             if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
                 $scheme = 'https';
             }
         }
         self::$url_base = "{$scheme}://{$_SERVER['HTTP_HOST']}{$path}";
     }
     return self::$url_base . $uri;
 }