fun php,PHPFun.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;

}

}

一键复制

编辑

Web IDE

原始数据

按行查看

历史

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值