问题
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