문제

I want to include a file called script.php this file is in the includes folder. When I do this:
include('/includes/script.php');

There is nothing happend, I get a error message that the file is not found. But when I do this:
include($_SERVER['DOCUMENT_ROOT'] . '/includes/script.php');

It works!, But $_SERVER['DOCUMENT_ROOT'] returns the base path of the document right?
But why is /includes/script.php not working? When you start a path with / means you go to the document root right?

도움이 되었습니까?

해결책

Yes if you start with / you are @ the Document root, but normaly your code on the server is in some subfolders you can use './includes/script.php'. The point means in the actual directory the includes folder.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top