Friday, June 29, 2007

PHP: Include? or Require

it's always confusing which one is which but there is an interesting way to memorize this.

require file is something that requires and very strict.
include is a little less strict.


require will generate error when you can't open file but
include won't generate error. include only generate error when you call function inside that file doesn't exist for example.

makes logical sense to:
require when you have a function / library php file and you want to use that file.
include can be used for html or something that's only partially crucial.



require_once should be used for functions, etc to avoid multiple declaration.

No comments: