tags:

views:

51

answers:

2

I'm looking for a way to include a bunch of files so that they're accessible on all pages (functions, classes). I read about "include_path" configuration in php.ini and decided to test it by placing a dummy function inside my "includes" directory. However, when I try to call it, there's a fatal error that says: "Call to undefined function".

Am I using the "includes" directory properly? if yes, what did I do wrong?

+4  A: 

No, include_path simply tells PHP in what directories to look when you do an include or require function call.

cmptrgeekken
so when a file is located inside the include_path, can I include it in my php code by simply specifying its name like this: include("dummy.php");
sombe
To further elaborate, include_path is where PHP will look if you include a relative path like `include('myfile.php');` rather than an absolute path like `include('/var/www/html/myfile.php');`
Frank Farmer
Gal: Yes. If dummy.php is in your include path, you can then `include("dummy.php");`
Frank Farmer
@Frank Farmer, so the answer to my question would be yes?
sombe
ok thanks a lot!
sombe
A: 

The include path is a directory that is searched to find included files. This allows you to put them somewhere different from the pages that get directly accessed.

Anon.