PHP - web hosting account name or root directory

Posted on 2011-09-23
Last Modified: 2012-05-12
Is there a call to a system function to show the root path.
In the end i need to plug in the username of the account, as in the example below


it could even be the path to "this" file and i can then strip off the unneeded subdirectories manually

in order to programmatically generate a root path for PHP files

Question by:willsherwood
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 11

Accepted Solution

maeltar earned 400 total points
ID: 36586805
This sill give you the document root..


Open in new window


Assisted Solution

mustang83 earned 100 total points
ID: 36586825
$_SERVER["SITE_HTMLROOT"] will give the server root path.

This will only work if you site is not a virtual  or an alias in apache.

There is also dirname which might work


Expert Comment

ID: 36586834
Here is a list of reserved variables that your might find handy.


Author Closing Comment

ID: 36587587
thanks all - the PHP filesystem root was what i was after

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question