php包含目录中的路径问题

Happy new year everyone... I have been working on a project and my file structure is

index.php

functions

profile

includes

main forlder is "mysite"

I have a header and footer if I include into the index.php its fine if I include in profile/index.php I get and error

I have tried to use

include($_SERVER['DOCUMENT_ROOT'] . '/header.php');

but have had not success still errors

the error I get when trying to go to profile/index.php

Warning: include(C:/Program Files (x86)/Zend/Apache2/htdocs/header.php): failed to open stream: No such file or directory in C:\Program Files (x86)\Zend\Apache2\htdocs\mysite\profile\index.php on line 2

if you look at the top warning its trying to include from htdocs however the site main folder is mysite

Your main folder is mysite, so add mysite after $_SERVER['DOCUMENT_ROOT'] for profile/index.php the code will be like this:

include($_SERVER['DOCUMENT_ROOT'] . '/mysite/includes/header.php');