Author Topic: [SOLVED] help on include ...  (Read 433 times)

0 Members and 1 Guest are viewing this topic.

Offline ~n[EO]n~Topic starter

  • Devotee
  • Posts: 725
    • View Profile
[SOLVED] help on include ...
« on: October 05, 2007, 03:30:14 AM »
can someone help on this please

Code: [Select]
include("config.php");
include("includes/user_info.class.php");

Code: [Select]
require_once("config.php");
require_once("user_info.class.php");

This both thing does the same thing, but which one is better to use any ideas ???

I got this from the manual but could not understand....

Quote
The documentation below also applies to require(). The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless. Be sure to have an appropriate include_path setting as well. Be warned that parse error in included file doesn't cause processing halting in PHP versions prior to PHP 4.3.5. Since this version, it does.


Offline heckenschutze

  • Enthusiast
  • Posts: 444
  • Gender: Male
    • View Profile
Re: help on include ...
« Reply #1 on: October 05, 2007, 03:33:50 AM »
Your script will stop if config.php can't be included if you use require(), for any reason. Ie it doesn't exist or PHP doesn't have privs to read the file.

include() will issue a warning if config.php cannot be included, but will continue running the script.

Use require() for vital files, and include() for other non-vital things.

Offline anujgarg

  • Enthusiast
  • Posts: 191
  • Gender: Male
    • View Profile
    • Anuj Garg - A Professional Web Developer
Re: help on include ...
« Reply #2 on: October 05, 2007, 03:48:42 AM »
You must use require() instead of include() as the former is faster in terms of execution than the latter.
Anuj Garg (http://anuj-blog.co.nr)

Express your thoughts here: http://www.myblogs.co.nr (and) http://www.anuj.8rf.com

Offline heckenschutze

  • Enthusiast
  • Posts: 444
  • Gender: Male
    • View Profile
Re: [SOLVED] help on include ...
« Reply #3 on: October 05, 2007, 06:10:24 AM »
> You must use require() instead of include() as the former is faster in terms of execution than the latter.
No it isn't.