php 类自动载入方法
<?php
class inload
{
/**
* 类自动载入,不需要由开发者调用
*
* @param string $class 类文件
*/
private function autoload( $class )
{
if( empty($class) )
{
throw new QException('加载文件不存在'.$class);
}
else
{
require _SPRING_.'/_Core/SpringMap.php'; //框架地图
if(! file_exists( $source[$class]['file'] ) )
{
throw new QException('加载文件不存在'.$class);
}
require $source[$class]['file'];
}
}
/**
* 注册或取消注册一个自动类载入方法
*
* 该方法参考 Zend Framework
*
* @param string $class 提供自动载入服务的类
* @param boolean $enabled 启用或禁用该服务
*/
private function registerAutoload($class = 'Interpreter' , $enabled = true)
{
if (!function_exists('spl_autoload_register'))
{
throw new QException('spl_autoload 不存在这个PHP的安装');
}
if ($enabled === true)
{
spl_autoload_register(array($class, 'autoload'));
}
else
{
spl_autoload_unregister(array($class, 'autoload'));
}
}
/**
* 析构函数
*/
public function __destruct()
{
self::registerAutoload('Interpreter' , false);
}
以上所述就是本文的全部内容了,希望大家能够喜欢。
动态WEB网站中的PHP和MySQL详细反映实际程序的需求,仔细地探讨外部数据的验证(例如信用卡卡号的格式)、用户登录以及如何使用模板建立网页的标准外观。动态WEB网站中的PHP和MySQL的内容不仅仅是这些。书中还提到如何串联JavaScript与PHP让用户操作时更快、更方便。还有正确处理用户输入错误的方法,让网站看起来更专业。另外还引入大量来自PEAR外挂函数库的强大功能,对常用的、强大的包
508
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号