ddc
联网
平面设计 画册 VI欣赏 包装 CG-插画 搜索 个人网页 Alexa排名 CSS 建站资源 下载专区 JS特效 品牌服装 服装院校 专题欣赏 SEO 图标欣赏 专题
网站建设 域名注册 网站建设 虚拟主机 广州网站设计 域名注册 广州网站建设 上海网站建设 虚拟主机 广州网页设计 虚拟主机 域名注册 acg王国 ACG玩家 品牌设计 上海网站建设
求创科技
网站建设
中国互联
素材出售
中国设计秀
中资源
当前位置:网络学院首页 >> 编程开发 >> php >> PHP5自动加载实现方法及代码

PHP5自动加载实现方法及代码 (1)

来源:中国设计秀    作者:    点击:100     加入收藏    发表评论
0
顶一下

<?php
/*------------------------------------------------------------------*/
if (strtoupper(substr(PHP_OS, 0, 3)) === ’WIN’) {
    if(!defined(’NEWLINE’)){
        define(’NEWLINE’, " ");
    }
} else {
    if(!defined(’NEWLINE’)){
        define(’NEWLINE’, " ");
    }
}


/*------------------------------------------------------------------*/
if(!defined(’HTMLNEWLINE’)){
    define(’HTMLNEWLINE’, ’<br/>’);
}


/*------------------------------------------------------------------*/
if(!defined(’CURRENT_TIMESTAMP’)){
    define(’CURRENT_TIMESTAMP’, time());
}
if(!defined(’FORMAT_DATE’)){
    define(’FORMAT_DATE’, ’Y-m-d’);
}

if(!defined(’TIMESTAMP’)){
    define(’TIMESTAMP’, ’Y-m-d H:i:s’);
}


/*------------------------------------------------------------------*/
if(!defined(’SECONDS_HOUR’)){
    define(’SECONDS_HOUR’, 3600);
}

if(!defined(’SECONDS_DAY’)){
    define(’SECONDS_DAY’, 3600 * 24);
}

if(!defined(’SECONDS_WEEK’)){
    define(’SECONDS_WEEK’, 3600 * 24 * 7);
}


?>

<?php

require_once ’Constants.php’;

class Autoload {

    /**
     * 注册容器,包括路径,类名和文件扩展名容器,可以赋默认值
     */
    public  $containers = array (
        ’includePaths’,
        ’classNames’,
        ’extensionNames’
    );
    /*--------- 类搜索路径列表 ------------*/
    public  $includePaths = array ();
    
    /*--------- 类名称列表 ------------*/
    public  $classNames = array ();
    
    /*--------- 类文件扩展名列表 ------------*/
    public  $extensionNames = array ();

    public function __construct() {     /* 默认搜索路径 */
        array_push( $this->includePaths, ’.’, ’lib’, ’classes’);
        
        /* 默认扩展名列表 */
        array_push( $this->extensionNames, ’.php’,’.class.php’);
        
        /* 自动加载函数注册 */
        if (method_exists( $this, ’__autoload’)) {
            spl_autoload_register(array( $this, ’__autoload’));
        }
        
    }     /**

[1] [2] [3]
2007-08-13 16:36:00    出处:
Google
热点文章/相关文章
网站地图 | 关于我们 | 联系我们 | 网站建设 | 广告服务 | 版权声明 | 免责声明 | 网站公告 | 友情链接 | 留言 | 旧版入口