0

I am working on local server, but I am having problem including files, even with full path given. eg, I have a file /home/[user]/public_html/vt/test.php like this:

<?php    
 include_once('/home/<user>/public_html/vt/Menu.php');
 print "included_once called.\n";     
?>

I got error in error_log:

failed to open stream: No such file or directory 

/home/[user]/public_html/vt/Menu.php exists, and access right is:

-rwxr-xr-x. 1 <user> apache 3906 Jul  5 08:43 <full/path/of/the/file>

The local documentRoot folder is set to (recursively):

drwxr-xr-x.  4 <user> apache     4096 Jul 26 14:06 public_html

So what is wrong?

Aruna
  • 11,959
  • 3
  • 28
  • 42
user1866880
  • 1,437
  • 6
  • 18
  • 26
  • *"So what is wrong?"* - The file or directory doesn't exist. – deceze Jul 30 '13 at 12:32
  • @deceze LIke I said, I have use ls -l to test the file path, it exists, and has 755 rights. – user1866880 Jul 30 '13 at 12:39
  • 1
    @JonathanRomer is to be replaced with a real user name. I don't want to disclose the user account name here. It could be john or Jane or waht ever. – user1866880 Jul 30 '13 at 12:39
  • One often runs into this error, and to quickly troubleshoot it, follow these steps : http://stackoverflow.com/a/36577021/2873507 – Vic Seedoubleyew Apr 12 '16 at 16:57
  • Possible duplicate of [Failed to open stream : No such file or directory](http://stackoverflow.com/questions/36577020/failed-to-open-stream-no-such-file-or-directory) – Vic Seedoubleyew Apr 30 '16 at 14:21

1 Answers1

3

try something like that: (DIR is a magic constant which contains the directory of the current file)

include_once dirname(__FILE__).'/Menu.php';

// PHP >= 5.3
include_once __DIR__.'/Menu.php';
bitWorking
  • 12,485
  • 1
  • 32
  • 38