Difference Between include and require Statements in PHP

PHP include and require Statements:

The include and require statements are identical, except upon failure:
require will produce a fatal error (E_COMPILE_ERROR) and stop the script.
include will only produce a warning (E_WARNING) and the script will continue.
 

Including files saves a lot of work. This means that you can create a standard header, footer, or menu file for all your web pages. Then, when the header needs to be updated, you can only update the header include file.



<html> 

<body>

 <div class="menu">
<?php include 'menu.php';?> 

</div>

 <h1>Welcome to my home page!</h1>
 <p>Some text.</p>
</body> 

</html> 

Post a Comment

0 Comments