• phpccma常用函数记录


        /**
         * 加载类文件函数
         * @param string $classname 类名
         * @param string $path 扩展地址
         * @param intger $initialize 是否初始化
         */
        private static function _load_class($classname, $path = '', $initialize = 1) {
         //$path 为空则为 load_sys_class
         //$path 为'model'则为 load_model
        //$path 为'modules'+DIRECTORY_SEPARATOR+$m+DIRECTORY_SEPARATOR+'classes'则为load_app_class
    static $classes = array(); if (empty($path)) $path = 'libs'.DIRECTORY_SEPARATOR.'classes'; $key = md5($path.$classname); if (isset($classes[$key])) { if (!empty($classes[$key])) { return $classes[$key]; } else { return true; } } if (file_exists(PC_PATH.$path.DIRECTORY_SEPARATOR.$classname.'.class.php')) { include PC_PATH.$path.DIRECTORY_SEPARATOR.$classname.'.class.php'; $name = $classname; if ($my_path = self::my_path(PC_PATH.$path.DIRECTORY_SEPARATOR.$classname.'.class.php')) { include $my_path; $name = 'MY_'.$classname; } if ($initialize) { $classes[$key] = new $name; } else { $classes[$key] = true; } return $classes[$key]; } else { return false; } } /** * 加载函数库 * @param string $func 函数库名 * @param string $path 地址 */ private static function _load_func($func, $path = '') {
        //$path 为空该函数则成了load_sys_func
        //$path 为'modules'.DIRECTORY_SEPARATOR.$m.DIRECTORY_SEPARATOR.'functions'则为load_app_func
        
    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; } /** * 加载配置文件 * @param string $file 配置文件 * @param string $key 要获取的配置荐 * @param string $default 默认配置。当获取配置项目失败时该值发生作用。 * @param boolean $reload 强制重新加载。 */ public static function load_config($file, $key = '', $default = '', $reload = false) {
        //返回 "cache/$file"->key 对应的值
    static $configs = array(); if (!$reload && isset($configs[$file])) { if (empty($key)) { return $configs[$file]; } elseif (isset($configs[$file][$key])) { return $configs[$file][$key]; } else { return $default; } } $path = CACHE_PATH.'configs'.DIRECTORY_SEPARATOR.$file.'.php'; if (file_exists($path)) { $configs[$file] = include $path; } if (empty($key)) { return $configs[$file]; } elseif (isset($configs[$file][$key])) { return $configs[$file][$key]; } else { return $default; } }
  • 相关阅读:
    Java_Eclipse_Android安装
    deep_learning_Function_os.makedirs()
    deep_learning_Function_ Matplotlib 3D 绘图函数 plot_surface 的 rstride 和 cstride 参数
    deep_learning_Function_ numpy.random.randn()
    deep_learning_Function_list变量前面加星号,字典变量前面加两个星号
    deep_learning_Function_ lambda函数详解
    Unity 3D中C#的性能优化小陷阱
    1.Bacula各组件说明
    vmware修改虚拟机名称
    AWS IoT Greengrass 入门-模块3(第 1 部分):AWS IoT Greengrass 上的 Lambda 函数
  • 原文地址:https://www.cnblogs.com/shallwe99/p/5523807.html
Copyright © 2020-2023  润新知