Php Showing Examples of Include and Require Functions

 

Include(""); is Used to include an external PHP file into the main PHP file.

External File

(Example.php)


<?php

echo "its an example of include";

?>


Now let's Embed this File into the main PHP file.

MAIN FILE

(hello.php)


<?php

echo "hello world","<br>";

echo "below is the example","<br>";

include("example.php");

?>


Require Function Example Can be shown using the same external file i.e(example.php)

(require.php)

<?php
echo "hello world","<br>";
echo "below is the example","<br>";
require("example.php");
?>






Comments