Page 1 of 1

Document_root include showing blank page on localhost site

PostPosted: 20. April 2016 18:31
by Jimjim
Hey I hope you can help

I am using $_SERVER['DOCUMENT_ROOT']. for my PHP include

I recently started to use XAMP control panel v3.2.2, I may of missed a configuration setting somewhere but I'll try my best to explain the problem

My website index.php is located in the directory /website/ and I am including a file from a directory on the same level such as /example/

The include looks like this:
Code: Select all
include($_SERVER['DOCUMENT_ROOT'].'/example/config.php');

My PHP include works fine on the live server on my web-host, but when I try viewing the same site/page on my localhost machine I get a blank page, no errors in the error log, so I assume that I have the include set up correctly but the content isn't showing

I have setup an entry in httpd-vhosts.conf that looks like this:
Code: Select all
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/my_site"
ServerName test.dev
ServerAlias www.test.dev
<Directory "C:/xampp/htdocs/my_site">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

And I have also changed my hosts file with these 2 entries:
Code: Select all
127.0.0.1       www.test.dev
127.0.0.1       test.dev

If the files are being included from within a sub-directory, all works fine if I use this:
Code: Select all
include("folder_name/config.php");

But I want to keep my current file-structure

Thanks!

Re: Document_root include showing blank page on localhost si

PostPosted: 02. May 2016 16:25
by Jimjim
thanks for the help :?

Re: Document_root include showing blank page on localhost si

PostPosted: 02. May 2016 17:13
by Altrea
Hi,

Did you try to print out $_SERVER['DOCUMENT_ROOT'].'/example/config.php to see whats in there?

Best wishes,
Altrea