How do I get root folder?

I have a structure folder as follow:

C:\xampp\htdocs\demo\ he-affable-bean\web-inf\include
C:\xampp\htdocs\demo\ he-affable-bean\web-inf\view

In clude folder, I have two files are header.php and footer.php. In the files of view, I include them into. In index.php, I do the same.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="../../css/affablebean.css" />
    <title>Affable Bean</title>
</head>
<body>
	<div id="main">
		<div id="header">
			<div id="widgetBar">
				<div class="headerWidget">
					[language]
				</div><!-- end .headerWidget -->
				
				<div class="headerWidget">
					[cart]
				</div><!-- end .headerWidget -->
	
				<a href="#">
					<img src="../../img/logo.png" id="logo" alt="" />
				</a>
				
				<a href="index.php">
					<img src="../../img/logoText.png" id="logoText" alt="" />
				</a>
			</div><!-- end #widgetBar -->
		</div><!-- end #header -->

As all you know, when we can access in upper folder by use …/ to do something. In the view folder, I can include file css in css folder by

…/…/css/affablebean.css
(1)

But in the file index.php, I can’t use (1) to access css file in css folder like this. I feel like take root folder to access any folders and files. If I use …/, and I have a lot of folders, it’s very disavantage. How can I do this with php? I use $_SERVER[‘DOCUMENT_ROOT’] but it’s not work.

Even though you are using XAMPP, the root folder on your local machine is not your site’s root folder. However, you can set upyour computer to work the way you want by setting up virtual hosts:

http://sawmac.com/xampp/virtualhosts/