0

I feel like an idiot, but I can't figure out what's wrong and every solution that I have tried (listed below) has failed.

Problem:

This doesn't work:

$settings = file_get_contents('settings'); \\ should search current directory

Where is this file Located?

/apps/foxyman/model/settings

What I have tried:

  1. Changing the include_path directive in php.ini to:

    .:/apps/foxyman

    And then restarting Apache. And yes, I did run phpinfo(); and verify that it was set.

  2. Changing the doc_root directive to the same thing in php.ini and restarting Apache.

  3. Changing the document root setting in the right httpd.conf file to: DocumentRoot "/apps/foxyman"

  4. $settings = file_get_contents('model/settings'); // should search include_path

And none of this works.

Yes, I know there are potentially other solutions that involve me setting the include path in every file, but I don't want to do that - I want to solve it once and not think about it again.

To me, and maybe I'm just an idiot (which you should feel free to let me know by telling me to go kill myself in the comments), but it seems ridiculous that php can't find the file in the the current directory AND doesn't seem to be searching the include path that I set. And before you ask, yes, the file does exists.

One more thing, here is the output for the following methods:

echo getcwd();
echo get_include_path();
echo $_SERVER['DOCUMENT_ROOT'];

/apps/foxyman/model
.:/apps/foxyman
/apps/foxyman
3
  • What about directory access privileges? I mean, is /model and its contents accessible to PHP (= web server)? Commented Dec 20, 2012 at 17:30
  • file_get_contents() doesn't use include_path by default, you have to pass it true as a second argument. Commented Dec 20, 2012 at 17:30
  • Also, try echoing getcwd() to see if it's actually what you think it is. Commented Dec 20, 2012 at 17:32

1 Answer 1

2

By default file_get_contents() does not use include path! If you want it to use the include path pass true in the second argument.

$settings = file_get_contents('settings', true);
Sign up to request clarification or add additional context in comments.

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.