当前位置: 首页>>代码示例>>PHP>>正文


PHP Environment::getMode方法代码示例

本文整理汇总了PHP中Environment::getMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::getMode方法的具体用法?PHP Environment::getMode怎么用?PHP Environment::getMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Environment的用法示例。


在下文中一共展示了Environment::getMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: detect

 /**
  * Detect environment mode.
  * @param  string mode name
  * @return bool
  */
 public function detect($name)
 {
     switch ($name) {
         case 'environment':
             // environment name autodetection
             if ($this->detect('console')) {
                 return Environment::CONSOLE;
             } else {
                 return Environment::getMode('live') ? Environment::PRODUCTION : Environment::DEVELOPMENT;
             }
         case 'live':
             // detects production mode by server IP address
             if (PHP_SAPI === 'cli') {
                 return FALSE;
             } elseif (isset($_SERVER['SERVER_ADDR'])) {
                 $oct = explode('.', $_SERVER['SERVER_ADDR']);
                 return count($oct) !== 4 || $oct[0] !== '10' && $oct[0] !== '127' && ($oct[0] !== '171' || $oct[1] < 16 || $oct[1] > 31) && ($oct[0] !== '169' || $oct[1] !== '254') && ($oct[0] !== '192' || $oct[1] !== '168');
             } else {
                 return TRUE;
             }
         case 'debug':
             // Determines whether the debugger is active
             if (defined('DEBUG_MODE')) {
                 return (bool) DEBUG_MODE;
             } else {
                 return !Environment::getMode('live') && isset($_REQUEST['DBGSESSID']);
                 // function_exists('DebugBreak');
             }
         case 'console':
             return PHP_SAPI === 'cli';
         default:
             // unknown mode
             return NULL;
     }
 }
开发者ID:laiello,项目名称:webuntucms,代码行数:40,代码来源:Configurator.php

示例2: detect

 /**
  * Detect environment mode.
  * @param  string mode name
  * @return bool
  */
 public function detect($name)
 {
     switch ($name) {
         case 'environment':
             // environment name autodetection
             if ($this->detect('console')) {
                 return Environment::CONSOLE;
             } else {
                 return Environment::getMode('production') ? Environment::PRODUCTION : Environment::DEVELOPMENT;
             }
         case 'production':
             // detects production mode by server IP address
             if (PHP_SAPI === 'cli') {
                 return FALSE;
             } elseif (isset($_SERVER['SERVER_ADDR']) || isset($_SERVER['LOCAL_ADDR'])) {
                 $addr = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
                 $oct = explode('.', $addr);
                 // 10.0.0.0/8   Private network
                 // 127.0.0.0/8  Loopback
                 // 169.254.0.0/16 & ::1  Link-Local
                 // 172.16.0.0/12  Private network
                 // 192.168.0.0/16  Private network
                 return $addr !== '::1' && (count($oct) !== 4 || $oct[0] !== '10' && $oct[0] !== '127' && ($oct[0] !== '172' || $oct[1] < 16 || $oct[1] > 31) && ($oct[0] !== '169' || $oct[1] !== '254') && ($oct[0] !== '192' || $oct[1] !== '168'));
             } else {
                 return TRUE;
             }
         case 'console':
             return PHP_SAPI === 'cli';
         default:
             // unknown mode
             return NULL;
     }
 }
开发者ID:jaroslavlibal,项目名称:MDW,代码行数:38,代码来源:Configurator.php

示例3: run

 /**
  * Dispatch an HTTP request to a routing debugger. Please don't call directly.
  */
 public static function run()
 {
     if (!self::$enabled || Environment::getMode('production')) {
         return;
     }
     self::$enabled = FALSE;
     $debugger = new self(Environment::getApplication()->getRouter(), Environment::getHttpRequest());
     $debugger->paint();
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:12,代码来源:RoutingDebugger.php

示例4: detect

 function detect($name)
 {
     switch ($name) {
         case 'environment':
             if ($this->detect('console')) {
                 return Environment::CONSOLE;
             } else {
                 return Environment::getMode('production') ? Environment::PRODUCTION : Environment::DEVELOPMENT;
             }
         case 'production':
             if (PHP_SAPI === 'cli') {
                 return FALSE;
             } elseif (isset($_SERVER['SERVER_ADDR']) || isset($_SERVER['LOCAL_ADDR'])) {
                 $addr = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
                 $oct = explode('.', $addr);
                 return $addr !== '::1' && (count($oct) !== 4 || $oct[0] !== '10' && $oct[0] !== '127' && ($oct[0] !== '172' || $oct[1] < 16 || $oct[1] > 31) && ($oct[0] !== '169' || $oct[1] !== '254') && ($oct[0] !== '192' || $oct[1] !== '168'));
             } else {
                 return TRUE;
             }
         case 'console':
             return PHP_SAPI === 'cli';
         default:
             return NULL;
     }
 }
开发者ID:romcok,项目名称:google-translator,代码行数:25,代码来源:loader.php


注:本文中的Environment::getMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。