开发者

Loading all codeigniter controller at the beginning

开发者 https://www.devze.com 2023-03-23 00:42 出处:网络
I\'ve a little problem. In a controller i will load a function wich is in otherController. I just use $pCtrl = new otherController;

I've a little problem.

In a controller i will load a function wich is in otherController.

I just use

$pCtrl = new otherController;

for loading the class in that otherControll开发者_运维知识库er.

The problem is that at that moment the otherController has not already been loaded. So the class is not available.

Can i find a way to tell codeigniter to load all controllers (folder controller) before doing other thing ?

Thanks for help.


This is bad practice. You should be using a CodeIgniter Library to do this instead.

Though, if you're already doing bad things, you could just open the /controllers directory in your config/autoload.php and configure codeigniter to autoload all available controllers. Not sure if this will work well (and efficiently) in practice, so try using libraries.


Its better to create a helper function or a library ..

oh btw , you can use HMVC also .

0

精彩评论

暂无评论...
验证码 换一张
取 消