1

I just took a look after how to send mail via google smtp.

PEAR appeared as the appropriate library to do the job.

In this code snippet there is a

require_once "Mail.php";

Where does this file resides? Does __autoload() function make some trick? If i change it to fit my classes' folder path I might broke the magic?

Community
  • 1
  • 1
Michael
  • 4,376
  • 10
  • 42
  • 66

2 Answers2

2

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.

AgentConundrum
  • 19,570
  • 6
  • 59
  • 99
1

It is looked in the include path http://php.net/manual/de/ini.core.php#ini.include-path

Fabian Blechschmidt
  • 3,858
  • 19
  • 36