require_once at the beginning or when really needed?

Posted by takeshin on Stack Overflow See other posts from Stack Overflow or by takeshin
Published on 2010-03-16T14:57:10Z Indexed on 2010/03/16 15:01 UTC
Read the original article Hit count: 169

Filed under:
|
|

Where should I put require_once statements, and why?

  1. Always on the beginning of a file, before the class,
  2. In the actual method when the file is really needed
  3. It depends
  4. ?

Most frameworks put includes at the beginning and do not care if the file is really needed.
Using autoloader is the other case here.

© Stack Overflow or respective owner

Related posts about php

Related posts about best-practices