PHP Require/Include

software development

#1

I am having some issues with requiring external classes in files.
At the top of index.php I have:
require “phpfunctions/objects.php”;

I have uploaded a file called objects.php which resides in a subfolder called phpfunctions. However, I am seeing the standard error:
Warning: require(phpfunctions/objects.php) [function.require]: failed to open stream: No such file or directory in /home/foo/bar.com/test/index.php on line xx

Fatal error: require() [function.require]: Failed opening required ‘phpfunctions/objects.php’ (include_path=’.:/usr/local/php5/lib/php:/usr/local/lib/php’) in /home/foo/bar.com/test/index.php on line xx

I have also tried putting the files in the same directory as index.php and adjusting the require statement accordingly, but to no avail.

I have done a bit of searching but everything seems to be about checking for file existence or not using URLs in the require statement because they are disabled by DreamHost.

Any ideas?


#2

It’s probably something you do :slight_smile:

1st) the filename “Objects.php” is different from “objects.php” - filenames are case-sensitive.

2nd) In the example above, your file must be in /home/foo/bar.com/test/phpfunctions/objects.php - You can try in a browser to access: http://foo.bar/test/phpfunctions/objects.php - it may return a blank page, but should not give any errors.


#3

Case-sensitive!? That is likely it, I’ve never worried about case sensitive file names.
Thanks!