...Beauty, cleaning, DIY tips and more - free to join!
   Login   Contact us   Site map   Puzzle Club   Ask a question    Newsletter

How To Require A File In PHP

Computing : Learning PHP

We know that to include a file in PHP that is optional but not fatal we use:
include ("myfile.php");

However there are occasions where we want the script to terminate if the file cannot be found.

For instance if it contains functions that are needed for the page and script to run correctly we will want to REQUIRE that file not just include it. Thus we use:

require ("myfile.php");

Now if the file cannot be found it will be a fatal error and script execution will terminate rather than with include where we just get a script error; depending on error_reporting levels.


Profile image!
By: Stephen

  More about learn PHP

  Reply to How To Require A File In PHP

  Receive Our Newsletter

  Send to friend

learn PHP picture



Questions about learn PHP:

Ask question

More Articles:
How to Synchronize Your Computer Clock with an Internet Time Server
Understanding email abbreviations
How to turn off review and markup in Word