How require_once in joomla2.5

邮差的信 提交于 2019-12-08 05:18:55

问题


I Have a problem about require_once in joomla.

In this file php:

components\com_test\views\__test_r5\tmpl\default.php

I want to include some file using this code:

require_once (JPATH_ROOT.DS.'/includes/General.php');

but require_once does not works


回答1:


The path you are trying to include will evaluate to something like: joomla//includes/General.php. Notice the double slashes before "includes". The constant DS is defined to be a directory separator.

Try:
require_once (JPATH_ROOT.'/includes/General.php');
 (without DS)




回答2:


Try This :

require_once(JPATH_SITE.DS."includes/General.php");

The JPATH_SITE will return your physical path upto : installation folder.

also JURI::root() will return your site url



回答3:


The best way to do this is to use @Fnatte variant.

Also have a look at the Joomla! constants definitions and adapt where needed.



来源:https://stackoverflow.com/questions/13219043/how-require-once-in-joomla2-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!