CodeIgniter:加载控制器文件中的助手与配置之间的区别 [英] CodeIgniter: difference between loading a helper in a controller file vs config

查看:128
本文介绍了CodeIgniter:加载控制器文件中的助手与配置之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道

function __construct()
{
    parent::__construct();
    $this->load-> helper('file');
}

这在我的控制器文件之一vs

this inside one of my controller file vs

$autoload['helper'] = array('file'); 

对于第二个选项,它会减慢应用程序只是一点点,因为这些帮助函数可以使用在可能不需要的地方(说一半的应用程序)。

For the 2nd option, would it slow down the application just a little bit because these helper functions may be used where it may not be needed (say half the application).

推荐答案

区别?如果你有一个小网站,它可以忽略不计。但是如果你想压缩你的网站的最后一点的性能,最好只加载那些帮助者在他们需要的地方。加载它们仍然是一个I / O请求,几个函数调用和包含 - 这是开销,大规模可察觉。

The difference? If you have a small website, it's negligible. But if you want to squeeze your website to the last bit for performance, it's better to load those helpers only where they are needed. Loading them is still an I/O request, several function calls and includes - which is overhead, noticeable in large scale.

这就是为什么你很少需要在页面中的大多数帮助者可选地加载(更不用说可选模型)。

codeigniter is focused on speed, that's why most of the helpers you rarely need in a page are loaded optionally (not to mention an optional model).

这篇关于CodeIgniter:加载控制器文件中的助手与配置之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆