1
votes

Im trying to require some php files into my main index.php but I get the following error:

Warning: require(/opt/lampp/htdocs/steamauth/userinfo.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/index.php on line 4

Fatal error: require(): Failed opening required '/opt/lampp/htdocs/steamauth/userinfo.php' (include_path='/opt/lampp/htdocs/') in /opt/lampp/htdocs/index.php on line 4

I tried the adding the following code:

set_include_path('/opt/lampp/htdocs/');
require dirname(__FILE__).'/steamauth/steamauth.php';

My include files steamauth.php and userinfo.php are at /opt/lampp/htdocs/steamauth/ I also tried setting the include_path in the php.ini file as well as adding it to my .htaccess file . And yes, I am sure that this is the correct path that I want to include. Any ideas?

2
Did you already try restarting your server? I ran into this problem using XAMPP. I edited the PHP.ini file and it did not work. When I restarted the XAMPP control panel, it worked fine with no modificaitons. - Joachim Rives

2 Answers

1
votes

I had the same problem trying to add a new directory to php path. I solved it adding double quotation marks surrounding the include_path in the php.ini file. Something like this:

include_path="C:\xampp\php\PEAR;c:\xampp\smarty\smarty-3.1.30\libs";
0
votes

What's your project folder structure ? Simply, try getting path right from index.php.

// /root/fooDir/userinfo.php
// /root/barDir/index.php

//in index.php
$dir = __DIR__ . '/../fooDir/userinfo.php';