Sunday, February 27, 2011

What is the difference between include and require in PHP?

What is the difference between include and require in PHP?

<?php include("Home.php"); ?>

<?php require("Page1.php"); ?>

The two functions are used to insert the content of a file into another PHP file before it is executed by the server. They are identical in every aspect, but they perform error handling in different ways. The include() function generates a warning (which does not halt execution) while the require() function generates a fatal error (which stops execution immediately).
 



No comments:

Post a Comment