How to include PHP page
How to include PHP page
1 Answer
Include page usually used when you want to duplicate part of a page in more than one page
such as the header and footer of the site
There are two functions to include PHP page to another page.
require() Function
Example
header.php
<!doctype html>
<html>
<head>
<title>Hello, world!</title>
</head>
index.php
<?php include("header.php"); ?>
<body>
</body>
</html>
now run the index.php and look to the source code from the browser
you can see
<!doctype html>
<html>
<head>
<title>Hello, world!</title>
</head>
<body>
</body>
</html>
include() Function
The same of require() Function, but the difference between include() and require() is, If the include() can`t load the page the script will continue and emit a warning but require() will emit a fatal error and stop the script.
answer Link