时时商务社区
标题:
php导入模块文件分享
[打印本页]
作者:
xgnic
时间:
2018-2-14 05:48
代码很简单,大家注意看注释就可以了。
[U]复制代码[/U] 代码如下:
/**
* 导入模块文件
*
* @param string $classString 导入文件路径字符串,可以用"."代替"/"
* @param string $fileType 导入文件类型的扩展名(带"."号),也可以是class/inc(简写方式)
* @return Exception 如果导入成功则返回true,否则返回异常对象
*
* @example
* importModule('gapi.Account') => include_once('modules/gapi/Account.class.php');
*/
function importModule($classString, $fileType = 'class')
{
$filename = $module_path. strtr($classString, '.', '/');
switch ($fileType) {
//导入类文件
case 'class': $filename .= '.class.php'; break;
//导入包含文件
case 'inc': $filename .= '.inc.php'; break;
//自定义导入文件的扩展名
default: $filename .= $fileType; break;
}
if (is_file($filename))
{
include_once($filename);
}
else
{
exit('class "[url=file://\\']\\'[/url] . strtr($classString, '.', '\\') . '" is not found.');
}
}
以上就是本文分享给大家的代码了,希望大家能够喜欢。
您可能感兴趣的文章:
php 将excel导入mysql
实战mysql导出中文乱码及phpmyadmin导入中文乱码的解决方法
PHP导入Excel到MySQL的方法
php导入导出excel实例
利用phpExcel实现Excel数据的导入导出(全步骤详细解析)
利用phpexcel把excel导入数据库和数据库导出excel实现
php导入csv文件碰到乱码问题的解决方法
ThinkPHP使用PHPExcel实现Excel数据导入导出完整实例
ThinkPHP模版中导入CSS和JS文件的方法
php将csv文件导入到mysql数据库的方法
欢迎光临 时时商务社区 (http://bbs.4435.cn/)
Powered by Discuz! X3.2