如何找到Joomla根目录

如何找到Joomla根目录,joomla,path,Joomla,Path,如何找到要在文件中使用的Joomla根目录?我尝试了以下方法,但没有成功: $path = JPATH_COMPONENT; //Gives component root $path = JURI::root(); //Gives absolute path, can't be used for some reason (http://www.site.com) $path = $_SERVER['DOCUMENT_ROOT']; //Giv

如何找到要在文件中使用的Joomla根目录?我尝试了以下方法,但没有成功:

    $path = JPATH_COMPONENT; 
    //Gives component root

    $path = JURI::root();
    //Gives absolute path, can't be used for some reason (http://www.site.com)

    $path = $_SERVER['DOCUMENT_ROOT'];
    //Gives public_html folder, but if someone installs joomla in a directory and not in root, it wrecks the whole thing
有没有办法只找到网站的joomla根?谢谢。

这可能对你有帮助

假设您想要包含来自images文件夹的图像,您可以简单地使用:

$image = JUri::root() . 'images/image_name.png';

JUri::root()
JUri::site()
始终定义根目录

@Flimm-在编辑之前的初始问题中,OP提到包含来自
图像
目录的文件,因此我假设它是一个图像;)