0

I want to know the best way to link back to my main folder both in my local server and when uploaded to my main server because I don't want to pass through the stress of editing my code all over again when I want to upload it and I want to achieve this through php.

I know the / would work but it only works when I echo it out, if I did something like this include '/connect.php' I get this error in my main server:

Warning: include(/tutorials/): failed to open stream: No such file or directory in /home/stephens/public_html/kings/home.php

I also get an error in my local server saying:

Warning: include(C:\wamp\www\projects\tutorials) [function.include]: failed to open stream: Permission denied in C:\wamp\www\home.php.

I tried this also $_SERVER['DOCUMENT_ROOT'] but Its not working in my main server, only for the local server.

I also used $_SERVER['SERVER_NAME'] but It's not working also.

Please does anyone have a better way of achieving this?

scott_lotus
  • 3,171
  • 22
  • 51
  • 69
KANAYO AUGUSTIN UG
  • 2,078
  • 3
  • 17
  • 31
  • Try using `__DIR__`, but *permission denied* and *no such file found* errors are different. The one was found but had wrong permissions so this wouldn't fix that. – Rasclatt May 08 '16 at 08:54
  • Indeed. You will find your answer in the answer to this question : http://stackoverflow.com/questions/36577020/failed-to-open-stream-no-such-file-or-directory – Vic Seedoubleyew May 15 '16 at 21:22

0 Answers0