Difference Between include and require Statements in PHP - CodeTextPro | Free Web Tutorial

Codetextpro Provides free Web tutorial, HTML, CSS, C, C++, Java, JavaScript, PHP, MySql, Python, Program, Programming Notes, Programming Questions and more.

Programming

Monday, December 10, 2018

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> 

No comments:

Post a Comment