How to find Joomla root directory

Viewed 30885

how to I find out the Joomla root directory to use in files? I tried the following with no luck:

    $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

Is there a way to find the joomla root of the site only? Thanks.

2 Answers
Related