【发布时间】:2016-05-16 17:10:39
【问题描述】:
我不想编写一个基于文件夹模型中的文件自动加载 :) 模型的函数。所以应用程序必须扫描文件夹中的文件,grep 所有 .php 文件,删除 .和..“文件夹”并将它们放在autoload['model'] = array
这是我当前在 autoload.php 文件中的代码
$dir = './application/models';
$files = scandir($dir);
unset($files[0]);
unset($files[1]);
$mods = '';
foreach ($files as $f){
if(glob('*.php') ){
$mods .= str_replace('.php','',"'".$f."',");
}
}
$autoload['model'] = $mods;
而且我不断收到类似的错误
An uncaught Exception was encountered
Type: RuntimeException
Message: Unable to locate the model you have specified: 'admins','categories','companies','countries'
Filename: D:\wamp64\www\myapp\public_html\rest\system\core\Loader.php
Line Number: 344
看起来问题是当我将数组传递给 $autoload 变量时,它会威胁整个数组作为一个模型。你们能帮我解决我的问题吗?
【问题讨论】:
-
编辑,现在我看到您想将该函数放在第 135 行之前。
标签: php codeigniter