Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道如何将助手自动包含到组件的所有模型文件中,我只需要从模型文件中的助手类创建对象?
避免使用require_once, 并使用正确的 Joomla 方法来包含辅助类
require_once
JLoader::register('ClassName', 'path_to_class');
将此代码段放在组件入口控制器的开头。Joomla 将仅在需要时自动加载该类。
通过使用常规 PHP require_once,您将减慢代码速度,因为文件会立即加载到内存中,即使不需要它也是如此。