use*_*324 17 configuration codeigniter declaration
我正在使用codeigniter 2.
感谢是否有人能够显示正确的方法来检查以下文件:
- 库文件是否已加载?
- 加载了帮助文件?
- 配置文件已加载?
- 模型文件已加载?
- 加载了third_party文件?
问候
Mar*_*sić 24
在调用之前,您可以使用本机PHP函数class_exists()来确定是否已定义类.同样,使用method_exists()将检查是否存在类方法.
由于帮助器是函数的集合,而不是方法,因此可以使用function_exists()来完成检查.
if (class_exists('Library'))
{
$this->library->myMethod();
}
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅
http://php.net/manual/en/function.class-exists.php.
http://us.php.net/manual/en/function.method-exists.php
min*_*ost 10
您无需检查,只需将它们加载到需要确保拥有它们的任何位置即可.
使用CI的Load库($this->load->[library|model|helper])将始终只加载一次.如果打开调试日志记录,则可以看到此信息.
这是用于检查加载的库的codeigniter方法.
//If the library is not loaded, Codeigniter will return FALSE
if(!$this->load->is_loaded('session'))
{
$this->load->library('session');
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16553 次 |
| 最近记录: |