当前位置: 首页>>代码示例>>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;未经允许,请勿转载。