0

I'm facing a problem when I'm trying to include a certain file. When I try to load the file I face this error :

failed to open stream: No such file or directory in ...

On the other hand , a <a href="/wT/sys/background.php">background</a> sends me directly to the file I want to include ( not the source code of it , but the output)

How come the include function cannot access the file via the given path but I can access it using a href ? *I need to get the source code of the file , not only the output , otherwise I'd just include the http://.... path *I run the php code on localhost, if it matters

I also tried to chechk whether I need to reconfigure the php.ini file but I didn't find anything useful ( Include url is allowed altough , as I said , I don't need to use it)

Any suggestion would be helpful, Thanks in advance

4
  • 2
    /wT/sys/background.php is a root-relative url. In a browser, this means relative to the root of the site, i.e., sub.domain.com/. In a server-side environment like PHP, this means relative to the root of the hard-drive, i.e., c:/ on Windows or / on unix. Commented Jul 24, 2012 at 15:44
  • If so , what root should I set ? Thanks Commented Jul 24, 2012 at 15:46
  • 1
    Please make yourself comfortable with how the filesystem works, also the magic constants are useful. Additionally you do not show the code that creates the error, so your question can not be simply answered. You're making it more complicated as it needs to be, please improve your question by adding the missing PHP source-code. Commented Jul 24, 2012 at 15:48
  • You should define a BASE_URL and a BASE_PATH in your index.php Commented Jul 24, 2012 at 15:49

2 Answers 2

1

include $_SERVER['DOCUMENT_ROOT'] . '/wT/sys/background.php';

Sign up to request clarification or add additional context in comments.

Comments

0

If file you want to include is in the lower directory as the script into which you are trying to include it, then try:

include __DIR__.'/wT/sys/background.php';

or simply

include 'wT/sys/background.php';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.