-1

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?

Thom
  • 591
  • 4
  • 12
  • 30

1 Answers1

2

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.

mrbirne
  • 38
  • 5