|
|
加载模块下的函数
例如- pc_base::load_app_func('global');
复制代码
表示加载 当前模块下的函数 functions目录下global.func.php
源码
- /**
- * 加载应用函数库
- * @param string $func 函数库名
- * @param string $m 模型名
- */
- public static function load_app_func($func, $m = '') {
- $m = empty($m) && defined('ROUTE_M') ? ROUTE_M : $m;
- if (empty($m)) return false;
- return self::_load_func($func, 'modules'.DIRECTORY_SEPARATOR.$m.DIRECTORY_SEPARATOR.'functions');
- }
复制代码- /**
- * 加载函数库
- * @param string $func 函数库名
- * @param string $path 地址
- */
- private static function _load_func($func, $path = '') {
- static $funcs = array();
- if (empty($path)) $path = 'libs'.DIRECTORY_SEPARATOR.'functions';
- $path .= DIRECTORY_SEPARATOR.$func.'.func.php';
- $key = md5($path);
- if (isset($funcs[$key])) return true;
- if (file_exists(PC_PATH.$path)) {
- include PC_PATH.$path;
- } else {
- $funcs[$key] = false;
- return false;
- }
- $funcs[$key] = true;
- return true;
- }
复制代码
|
|