Please get in the habit of checking the manual before asking questions like this here. It covers this:
Files are included based on the file path given or, if none is given, the include_path specified. If the file isn't found in the include_path, include will finally check in the calling script's own directory and the current working directory before failing. The include construct will emit a warning if it cannot find a file; this is different behavior from require, which will emit a fatal error.
__autoload()
is a separate concept from include
and/or require
. It is a function which is automatically called when you try to use a class which has not yet been defined. It is a function you write yourself, to define your own algorithm for determining what files you need to include
, based on your project's file structure.
You should also avoid using __autoload()
in your code, since there can be only one __autoload()
function defined. Instead, you should use spl_autoload_register()
instead. This function takes the name of other functions and adds it to a list of functions that, when an unknown class is invoked, will each be called until one of them finds the file which defines the class you're looking for.