How to Use require() function in PHP?

require() function

The require method is used just like the include method to include the file.
But when we include the file using require method and if that file is not found then that require method stops the execution of the file and shows fatal error. The require method is specially used to create framework, cms or any large level application.

Syntax for require()

require("path_or_filename"); or
require('path_or_filename');

external_file.php

Source Code :
<?php
echo "external file name is external_file.php";
?>

Example for require() function

current_file.php

Source Code :
<?php
echo "current file name is current_file.php";
require ("external_file.php");
?>
Output :
current file name is current_file.php
external file name is external_file.php

Note: If we look about the require() function, then if the given path is wrong then the execution of the entire php code stops. Here it gives compilation error message.