Re: [PHP] another question on setting include paths for a project

[email protected] ("Robert P. J. Day")
Newsgroups php.general
Message-ID <alpine.LFD.2.00.1003221045020.25253@localhost>
On Mon, 22 Mar 2010, Richard Quadling wrote:

> Depending upon what is being included, an autoloader could help
> here.
>
> The main payoffs for autoloading are reduced memory footprint (class
> are loaded JIT) and no need for each class to know exactly where the
> other classes are.
>
> So, your main page needs to load the autoloader and the autoloader
> handles the loading of the classes.
>
> No need to change the include_path setting.

  ok, i'm looking at the PHP manual page for autoload, sample:

  function __autoload($class_name)
  {
    require_once $class_name . '.php';
  }

and some obvious questions suggest themselves:

1) in as simple an example as above, does the include_path still
control the search?  since i'm not doing anything fancy above in terms
of specifying *where* that class is defined, it seems that i'll still
have the same problem to solve, no?

2) i'm guessing that i can make the __autoload function as
sophisticated as i want, in that i can have it consult an environment
variable to determine where to search, but i'm still unsure as to how
i can set an environment variable to be consulted on the "server"
side.

rday
--

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

            Linux Consulting, Training and Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Twitter:                                       http://twitter.com/rpjday
========================================================================
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.