當前位置: 首頁>>代碼示例>>PHP>>正文


PHP N函數代碼示例

本文整理匯總了PHP中N函數的典型用法代碼示例。如果您正苦於以下問題:PHP N函數的具體用法?PHP N怎麽用?PHP N使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了N函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: showTime

 /**
 +----------------------------------------------------------
 * 顯示運行時間、數據庫操作、緩存次數、內存使用信息
 +----------------------------------------------------------
 * @access private
 +----------------------------------------------------------
 * @return string
 +----------------------------------------------------------
 */
 private function showTime()
 {
     // 顯示運行時間
     G('beginTime', $GLOBALS['_beginTime']);
     G('viewEndTime');
     $showTime = 'Process: ' . G('beginTime', 'viewEndTime') . 's ';
     // 顯示詳細運行時間
     $showTime .= '( Load:' . G('beginTime', 'loadTime') . 's Init:' . G('loadTime', 'initTime') . 's Exec:' . G('initTime', 'viewStartTime') . 's Template:' . G('viewStartTime', 'viewEndTime') . 's )';
     // 顯示數據庫操作次數
     if (class_exists('Db', false)) {
         $showTime .= ' | DB :' . N('db_query') . ' queries ' . N('db_write') . ' writes ';
     }
     // 顯示緩存讀寫次數
     if (class_exists('Cache', false)) {
         $showTime .= ' | Cache :' . N('cache_read') . ' gets ' . N('cache_write') . ' writes ';
     }
     // 顯示內存開銷
     if (MEMORY_LIMIT_ON) {
         $showTime .= ' | UseMem:' . number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024) . ' kb';
     }
     // 顯示文件加載數
     $showTime .= ' | LoadFile:' . count(get_included_files());
     // 顯示函數調用次數 自定義函數,內置函數
     $fun = get_defined_functions();
     $showTime .= ' | CallFun:' . count($fun['user']) . ',' . count($fun['internal']);
     return $showTime;
 }
開發者ID:yunsite,項目名稱:e-tuan001-com,代碼行數:36,代碼來源:ShowPageTraceBehavior.class.php

示例2: set

 /**
  * 寫入緩存
  * @access public
  * @param string $name 緩存變量名
  * @param mixed $value  存儲數據
  * @param integer $expire  有效時間(秒)
  * @return boolen
  */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     $expire = !empty($expireTime) ? $expireTime : C('DATA_CACHE_TIME');
     $name = $this->options['prefix'] . sqlite_escape_string($name);
     $value = sqlite_escape_string(serialize($value));
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     $expire = $expire == 0 ? 0 : time() + $expire;
     //緩存有效期為0表示永久緩存
     if (C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
         //數據壓縮
         $value = gzcompress($value, 3);
     }
     $sql = 'REPLACE INTO ' . $this->options['table'] . ' (var, value,expire) VALUES (\'' . $name . '\', \'' . $value . '\', \'' . $expire . '\')';
     if (sqlite_query($this->handler, $sql)) {
         if ($this->options['length'] > 0) {
             // 記錄緩存隊列
             $this->queue($name);
         }
         return true;
     }
     return false;
 }
開發者ID:omusico,項目名稱:jianli,代碼行數:33,代碼來源:CacheSqlite.class.php

示例3: showTime

 /**
  * 顯示運行時間、數據庫操作、緩存次數、內存使用信息
  * @access private
  * @return string
  */
 private function showTime()
 {
     // 顯示運行時間
     G('beginTime', $GLOBALS['_beginTime']);
     G('viewEndTime');
     $showTime = 'Process: ' . G('beginTime', 'viewEndTime') . 's ';
     if (C('SHOW_ADV_TIME')) {
         // 顯示詳細運行時間
         $showTime .= '( Load:' . G('beginTime', 'loadTime') . 's Init:' . G('loadTime', 'initTime') . 's Exec:' . G('initTime', 'viewStartTime') . 's Template:' . G('viewStartTime', 'viewEndTime') . 's )';
     }
     if (C('SHOW_DB_TIMES') && class_exists('Db', false)) {
         // 顯示數據庫操作次數
         $showTime .= ' | DB :' . N('db_query') . ' queries ' . N('db_write') . ' writes ';
     }
     if (C('SHOW_CACHE_TIMES') && class_exists('Cache', false)) {
         // 顯示緩存讀寫次數
         $showTime .= ' | Cache :' . N('cache_read') . ' gets ' . N('cache_write') . ' writes ';
     }
     if (MEMORY_LIMIT_ON && C('SHOW_USE_MEM')) {
         // 顯示內存開銷
         $showTime .= ' | UseMem:' . number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024) . ' kb';
     }
     if (C('SHOW_LOAD_FILE')) {
         $showTime .= ' | LoadFile:' . count(get_included_files());
     }
     if (C('SHOW_FUN_TIMES')) {
         $fun = get_defined_functions();
         $showTime .= ' | CallFun:' . count($fun['user']) . ',' . count($fun['internal']);
     }
     return $showTime;
 }
開發者ID:tifaweb,項目名稱:dswjshop,代碼行數:36,代碼來源:ShowRuntimeBehavior.class.php

示例4: set

 /**
 +----------------------------------------------------------
 * 寫入緩存
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 緩存變量名
 * @param mixed $value  存儲數據
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function set($name, $value, $expire = '')
 {
     N('cache_write', 1);
     if (empty($expire)) {
         $expire = $this->expire;
     }
     return xcache_set($name, $value, $expire);
 }
開發者ID:omusico,項目名稱:AndyCMS,代碼行數:20,代碼來源:CacheXcache.class.php

示例5: AK

 static function AK(AL $e, E $c) : E
 {
     $f = 'AJ';
     for ($g = 1, $h = N($c); $g < $e; $g++) {
         $f .= $c;
     }
     return $f;
 }
開發者ID:exakat,項目名稱:exakat,代碼行數:8,代碼來源:_Function.59.php

示例6: showTrace

 /**
  * 顯示頁麵Trace信息
  * @access private
  */
 private function showTrace()
 {
     // 係統默認顯示信息
     $files = get_included_files();
     $info = array();
     foreach ($files as $key => $file) {
         $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )';
     }
     $trace = array();
     $base = array('請求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . __SELF__, '運行時間' => $this->showTime(), '內存開銷' => MEMORY_LIMIT_ON ? number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024, 2) . ' kb' : '不支持', '查詢信息' => N('db_query') . ' queries ' . N('db_write') . ' writes ', '文件加載' => count(get_included_files()), '緩存信息' => N('cache_read') . ' gets ' . N('cache_write') . ' writes ', '配置加載' => count(c()), '會話信息' => 'SESSION_ID=' . session_id());
     // 讀取應用定義的Trace文件
     $traceFile = CONF_PATH . 'trace.php';
     if (is_file($traceFile)) {
         $base = array_merge($base, include $traceFile);
     }
     $debug = trace();
     $tabs = C('TRACE_PAGE_TABS', null, $this->tracePagTabs);
     foreach ($tabs as $name => $title) {
         switch (strtoupper($name)) {
             case 'BASE':
                 // 基本信息
                 $trace[$title] = $base;
                 break;
             case 'FILE':
                 // 文件信息
                 $trace[$title] = $info;
                 break;
             default:
                 // 調試信息
                 if (strpos($name, '|')) {
                     // 多組信息
                     $array = explode('|', $name);
                     $result = array();
                     foreach ($array as $name) {
                         $result += isset($debug[$name]) ? $debug[$name] : array();
                     }
                     $trace[$title] = $result;
                 } else {
                     $trace[$title] = isset($debug[$name]) ? $debug[$name] : '';
                 }
         }
     }
     foreach ($trace as $key => $val) {
         if (!is_array($val) && empty($val)) {
             $val = array();
         }
         if (is_array($val)) {
             $fire = array(array('', ''));
             foreach ($val as $k => $v) {
                 $fire[] = array($k, $v);
             }
             fb(array($key, $fire), FirePHP::TABLE);
         } else {
             fb($val, $key);
         }
     }
     unset($files, $info, $log, $base);
 }
開發者ID:RedrockTeam,項目名稱:LostAndFound,代碼行數:62,代碼來源:FireShowPageTraceBehavior.class.php

示例7: execute

 /**
  * 執行語句
  * 
  * @access public
  * @param string $str
  *            sql指令
  * @param boolean $fetchSql
  *            不執行隻是獲取SQL
  * @return integer
  */
 public function execute($str, $fetchSql = false)
 {
     $this->initConnect(true);
     if (!$this->_linkID) {
         return false;
     }
     $this->queryStr = $str;
     if (!empty($this->bind)) {
         $that = $this;
         $this->queryStr = strtr($this->queryStr, array_map(function ($val) use($that) {
             return '\'' . $that->escapeString($val) . '\'';
         }, $this->bind));
     }
     if ($fetchSql) {
         return $this->queryStr;
     }
     $flag = false;
     if (preg_match("/^\\s*(INSERT\\s+INTO)\\s+(\\w+)\\s+/i", $str, $match)) {
         $this->table = C("DB_SEQUENCE_PREFIX") . str_ireplace(C("DB_PREFIX"), "", $match[2]);
         $flag = (bool) $this->query("SELECT * FROM user_sequences WHERE sequence_name='" . strtoupper($this->table) . "'");
     }
     // 釋放前次的查詢結果
     if (!empty($this->PDOStatement)) {
         $this->free();
     }
     $this->executeTimes++;
     N('db_write', 1);
     // 兼容代碼
     // 記錄開始執行時間
     $this->debug(true);
     $this->PDOStatement = $this->_linkID->prepare($str);
     if (false === $this->PDOStatement) {
         $this->error();
         return false;
     }
     foreach ($this->bind as $key => $val) {
         if (is_array($val)) {
             $this->PDOStatement->bindValue($key, $val[0], $val[1]);
         } else {
             $this->PDOStatement->bindValue($key, $val);
         }
     }
     $this->bind = array();
     $result = $this->PDOStatement->execute();
     $this->debug(false);
     if (false === $result) {
         $this->error();
         return false;
     } else {
         $this->numRows = $this->PDOStatement->rowCount();
         if ($flag || preg_match("/^\\s*(INSERT\\s+INTO|REPLACE\\s+INTO)\\s+/i", $str)) {
             $this->lastInsID = $this->_linkID->lastInsertId();
         }
         return $this->numRows;
     }
 }
開發者ID:siimanager,項目名稱:sii,代碼行數:66,代碼來源:Oracle.class.php

示例8: set

 /**
 +----------------------------------------------------------
 * 寫入緩存
 *
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 緩存變量名
 * @param mixed $value  存儲數據
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 function set($name, $value, $ttl = null)
 {
     N('cache_write', 1);
     if (isset($ttl) && is_int($ttl)) {
         $expire = $ttl;
     } else {
         $expire = $this->expire;
     }
     return apc_store($name, $value, $expire);
 }
開發者ID:dalinhuang,項目名稱:concourse,代碼行數:23,代碼來源:CacheApc.class.php

示例9: set

 /**
 +----------------------------------------------------------
 * 寫入緩存
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 緩存變量名
 * @param mixed $value  存儲數據
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function set($name, $value, $ttl = null)
 {
     N('cache_write', 1);
     if (isset($ttl) && is_int($ttl)) {
         $expire = $ttl;
     } else {
         $expire = $this->expire;
     }
     eaccelerator_lock($name);
     return eaccelerator_put($name, $value, $expire);
 }
開發者ID:omusico,項目名稱:AndyCMS,代碼行數:23,代碼來源:CacheEaccelerator.class.php

示例10: set

 /**
  * 寫入緩存
  * @access public
  * @param string $name 緩存變量名
  * @param mixed $value  存儲數據
  * @param integer $expire  有效時間(秒)
  * @return boolean
  */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     $name = $this->options['prefix'] . $name;
     dump(json_encode(array('key' => $name, 'value' => $value, 'expire' => "" . $expire)));
     dump($this->options['root']);
     dump(file_post_contents($this->options['root'], json_encode(array('key' => $name, 'value' => $value, 'expire' => $expire))));
     return true;
 }
開發者ID:lizhengqiang,項目名稱:thinkphp,代碼行數:20,代碼來源:Mougememcached.class.php

示例11: set

 /**
 +----------------------------------------------------------
 * 寫入緩存
 *
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 緩存變量名
 * @param mixed $value  存儲數據
 * @param integer $expire  有效時間(秒)
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     if ($result = apc_store($name, $value, $expire)) {
         if ($this->options['length'] > 0) {
             // 記錄緩存隊列
             $this->queue($name);
         }
     }
     return $result;
 }
開發者ID:zhujunxxxxx,項目名稱:zzadmin,代碼行數:28,代碼來源:CacheApc.class.php

示例12: showTrace

 /**
  * 顯示頁麵Trace信息
  * @access private
  */
 private function showTrace()
 {
     // 係統默認顯示信息
     $files = get_included_files();
     $info = [];
     foreach ($files as $key => $file) {
         $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )';
     }
     $trace = [];
     Debug::remark('START', NOW_TIME);
     $base = ['請求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['PHP_SELF'], '運行時間' => Debug::getUseTime('START', 'END', 6) . 's', '內存開銷' => MEMORY_LIMIT_ON ? G('START', 'END', 'm') . 'b' : '不支持', '查詢信息' => N('db_query') . ' queries ' . N('db_write') . ' writes ', '文件加載' => count($files), '緩存信息' => N('cache_read') . ' gets ' . N('cache_write') . ' writes ', '配置加載' => count(Config::get())];
     // 讀取項目定義的Trace文件
     $traceFile = MODULE_PATH . 'trace.php';
     if (is_file($traceFile)) {
         $base = array_merge($base, include $traceFile);
     }
     $debug = Log::getLog();
     $tabs = Config::get('trace_page_tabs');
     foreach ($tabs as $name => $title) {
         switch (strtoupper($name)) {
             case 'BASE':
                 // 基本信息
                 $trace[$title] = $base;
                 break;
             case 'FILE':
                 // 文件信息
                 $trace[$title] = $info;
                 break;
             default:
                 // 調試信息
                 $name = strtoupper($name);
                 if (strpos($name, '|')) {
                     // 多組信息
                     $array = explode('|', $name);
                     $result = [];
                     foreach ($array as $name) {
                         $result += isset($debug[$name]) ? $debug[$name] : [];
                     }
                     $trace[$title] = $result;
                 } else {
                     $trace[$title] = isset($debug[$name]) ? $debug[$name] : '';
                 }
         }
     }
     unset($files, $info, $base, $debug);
     // 調用Trace頁麵模板
     ob_start();
     include Config::has('tmpl_trace_file') ? Config::get('tmpl_trace_file') : THINK_PATH . 'tpl/page_trace.tpl';
     return ob_get_clean();
 }
開發者ID:houseme,項目名稱:think,代碼行數:54,代碼來源:show_page_trace.php

示例13: set

 /**
 +----------------------------------------------------------
 * 寫入緩存
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $name 緩存變量名
 * @param mixed $value  存儲數據
 * @param integer $expire  有效時間(秒)
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     if (wincache_ucache_set($name, $value, $expire)) {
         if ($this->options['length'] > 0) {
             // 記錄緩存隊列
             $this->queue($name);
         }
         return true;
     }
     return false;
 }
開發者ID:yunsite,項目名稱:e-tuan001-com,代碼行數:28,代碼來源:CacheWincache.class.php

示例14: set

 /**
  * 寫入緩存
  * @access public
  * @param string $name 緩存變量名
  * @param mixed $value  存儲數據
  * @param integer $expire  有效時間(秒)
  * @return boolen
  */
 public function set($name, $value, $expire = null)
 {
     N('cache_write', 1);
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     $name = $this->options['prefix'] . $name;
     if ($this->handler->set($name, $value, 0, $expire)) {
         if ($this->options['length'] > 0) {
             // 記錄緩存隊列
             $this->queue($name);
         }
         return true;
     }
     return false;
 }
開發者ID:xibaachao,項目名稱:1bz,代碼行數:24,代碼來源:CacheMemcache.class.php

示例15: execute

 /**
  * 執行語句
  * 
  * @access public
  * @param string $str
  *            sql指令
  * @param boolean $fetchSql
  *            不執行隻是獲取SQL
  * @return mixed
  */
 public function execute($str, $fetchSql = false)
 {
     $this->initConnect(true);
     if (!$this->_linkID) {
         return false;
     }
     $this->queryStr = $str;
     if (!empty($this->bind)) {
         $that = $this;
         $this->queryStr = strtr($this->queryStr, array_map(function ($val) use($that) {
             return '\'' . $that->escapeString($val) . '\'';
         }, $this->bind));
     }
     if ($fetchSql) {
         return $this->queryStr;
     }
     // 釋放前次的查詢結果
     if (!empty($this->PDOStatement)) {
         $this->free();
     }
     $this->executeTimes++;
     N('db_write', 1);
     // 兼容代碼
     // 記錄開始執行時間
     $this->debug(true);
     $this->PDOStatement = $this->_linkID->prepare($str);
     if (false === $this->PDOStatement) {
         E($this->error());
     }
     foreach ($this->bind as $key => $val) {
         if (is_array($val)) {
             $this->PDOStatement->bindValue($key, $val[0], $val[1]);
         } else {
             $this->PDOStatement->bindValue($key, $val);
         }
     }
     $this->bind = array();
     $result = $this->PDOStatement->execute();
     $this->debug(false);
     if (false === $result) {
         $this->error();
         return false;
     } else {
         $this->numRows = $this->PDOStatement->rowCount();
         return $this->numRows;
     }
 }
開發者ID:gaoge00,項目名稱:sii,代碼行數:57,代碼來源:Firebird.class.php


注:本文中的N函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。