Ai
1 Star 0 Fork 16

哆来咪/phpfun

forked from ownfire/phpfun 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
PHPFun.php 2.13 KB
一键复制 编辑 原始数据 按行查看 历史
ownfire 提交于 2015-04-08 12:56 +08:00 . add validator class
<?php
/**
* php大量自定义的方便的函数
*
* @author wuxiao
* @date 20140626
*/
defined('DS') or define('DS',DIRECTORY_SEPARATOR);
defined('EXT') or define('EXT','.php');
defined('FUN_ROOT') or define('FUN_ROOT', realpath(dirname(__FILE__)).DS);
defined('FUN_CACHE') or define('FUN_CACHE', FUN_ROOT.'runtime'.DS.'cache'.DS);
defined('FUN_LOG') or define('FUN_LOG', FUN_ROOT.'runtime'.DS.'log'.DS);
defined('FUN_LIB') or define('FUN_LIB', FUN_ROOT.'lib'.DS);
defined('FUN_FUNC') or define('FUN_FUNC', FUN_ROOT.'func'.DS);
defined('FUN_KEY') or define('FUN_KEY', '1d2sbFIHzJLmaCSIB8aVsdPj2teSEvUqvxY7femSB2OLsbXs12DMlbPe');
//date_default_timezone_set('PRC');
class PHPFun{
protected $debug = true;
protected static $_instance;
public function __construct($namespace = null) {
$this->init($namespace);
self::$_instance = $this;
}
public static function getInstance(){
return self::$_instance;
}
public function load($namespace){
$namespace = basename($namespace, EXT);
$namespace = FUN_FUNC . $namespace . EXT;
return req_once($namespace);
}
private function init($namespace = null){
require_once FUN_ROOT.'init.php';
if (empty($namespace)){
$libs = glob(FUN_FUNC.'*.php');
array_walk($libs,'req_once');
}else{
$this->load($namespace);
}
spl_autoload_register(array($this,'lib_autoload'));
}
//php debug开启
public function debug(){
$this->debug = true;
ini_set('display_errors', true);
error_reporting(E_ALL);
}
//php debug关闭
public function nodebug(){
$this->debug = false;
ini_set('display_errors', false);
error_reporting(0);
}
private function lib_autoload($name){
$name = strtolower($name);
$file = FUN_LIB.'class_'.$name.EXT;
if (!is_file($file)){
if (!is_file($file = FUN_LIB.$name.DS.$name.EXT)){
return false;
}
}
include_once $file;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dlm2015/phpfun.git
git@gitee.com:dlm2015/phpfun.git
dlm2015
phpfun
phpfun
master

搜索帮助