PHP Include
EXPLAIN
The include (or require) statement takes all the text/code/markup that exists in the specified file and copies it into the file that uses the include statement.
Including files is very useful when you want to include the same PHP, HTML, or text on multiple pages of a website.
SYNTAX
include 'filename';
or
require 'filename';
or
require 'filename';
SAMPLE CODE & OUTPUT
<!DOCTYPE html>
<html>
<body>
<h1>Welcome to my home page!</h1>
<html>
<body>
<h1>Welcome to my home page!</h1>
<p>Some text.</p>
<p>Some more text.</p>
<?php include 'footer.php';?>
</body>
</html>
<p>Some more text.</p>
<?php include 'footer.php';?>
</body>
</html>
Output:
Welcome to my home page!
Some text.Some more text.
Reference:
http://www.w3schools.com/php/php_includes.asp
http://php.net/manual/en/function.include.php
No comments:
Post a Comment