-1

I'm trying to access a file inside a folder, but the problem is the variable is not working.

What I want is once the user visit the site the variable $site and path should be 'domain.com/inc.index.php'

here is my code

$site = $_SERVER['SERVER_NAME'];

include '$site/inc.index.php';

Error

include($site/inc.index.php): failed to open stream: No such file or directory

I found the same problem but its not working for me.

https://teamtreehouse.com/community/how-do-i-put-a-variable-inside-include-path

  • There is a troubleshooting checklist for this kind of problem here : http://stackoverflow.com/questions/36577020/failed-to-open-stream-no-such-file-or-directory – Vic Seedoubleyew Aug 20 '16 at 08:59

1 Answers1

3

You should use the double quote and not a single for that:

include "$site/inc.index.php";

The single quote will not parse the values of the variables in your string, while the double quote will.

Dekel
  • 60,707
  • 10
  • 101
  • 129
  • There is a troubleshooting checklist for this kind of problems here : http://stackoverflow.com/questions/36577020/failed-to-open-stream-no-such-file-or-directory – Vic Seedoubleyew Aug 20 '16 at 09:00