PHP Programming: The difference between require() and include()

php, programming, php programming, open source, php function
Many friends ask me what’s the difference between require() and include(). Here is the explaination from PHP manual.

From PHP manual:-

require() and include() are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, don’t hesitate to 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.


So that means, if you want to ensure that file1.php must be read before execute anything else, then you should use require.

If you just want to load a ‘not that important’ template header then you can use include function.

Technorati Tags: , , , , , , ,

If you want a dedicated hosting server that will be there when you need it, sign online today.  There are a plethora of web hosting companies to choose from.  You need to find an exchange server host that won’t let you down.  Whether you need a host for personal or business use, you need to research your host servers!

Share and Enjoy:
  • Reddit
  • BlinkList
  • del.icio.us
  • Digg
  • Fark
  • IndianPad
  • StumbleUpon
  • YahooMyWeb
Posted at October 1st, 2006 by chua

If you think this article helps you to solve your problem and clear your headache, feel free to buy me a drink :)

Related Post

5 Responses to “PHP Programming: The difference between require() and include()”

  1. vinod Says:

    HEllo dear,

    This is the very good and simple diff. every one can understood it from very easily.

    Thanks vinod

  2. Zebra Says:

    Indeed !!!

    Finally a simple explanation for a simple thing.

    Thank You

  3. adriene Says:

    Please, if you have free time, visit one website. I’d be grateful as once I applied at a website and got bad experience. The card didn’t come, maybe even someone stole it from postbox. But my friend recommended another site he recently found. Please, tell me if I can apply for a good credit card at
    ?
    balance transfer credit application

  4. Norhan Says:

    it’s the simplest way i’ve ever read about that differece

    thanks for your simple explanation

  5. dileep Says:

    i want php programming with explanation

Leave a Reply