path Issues through include with php

Viewed 20

I want to have more structure in my project so I add some folders. I had to change the includes / requires and found in google this code $root = realpath( $_SERVER["DOCUMENT_ROOT"] ); include "$root/some.php"; now i get an error

For example my project look like this: Project Tree

if I am in test.php I get this error:

error

my index.php code:

<?php
var_dump("I'm in index.php");
echo  ' <a href="customer.php">Customer.php</a>' ; 
?> 

my customer.php code:

<?php
var_dump("I'm in customer.php");
echo  ' <a href="php/functions/main/test.php">test.php</a>';
?> 

my test.php code:

<?php
$root = realpath( $_SERVER["DOCUMENT_ROOT"] );
var_dump("I'm in test.php");
include "$root/index.php"
?> 

or should I better use include "../../../index.php"; ?

thanks for your time

0 Answers
Related