include File
include file is used
to include the PHP, HTML, or text on multiple pages of a website.
You
can insert the content of one PHP file into another PHP file (before the server
executes it)with the include statement. That means you can reuse the code again
and again.
It
includes a specified file. It will produce a warning if it fails to find the
file and execute the remaining scripts
There
are two ways to include file in PHP.
1. include
2. require
Advantage:
Code Reusability
Advantage:
Code Reusability
Syntax:
include 'filename';
Example:
Lp.html
<a href="#">Home</a> |
<a href="
https://learningpoint92.blogspot.in/">Blog</a> |
<a href=" https://www.facebook.com/LearningPoint92/">Facebook</a> |
<a href=" https://twitter.com/LearningPoint92">twitter</a> |
<ahref="https://www.linkedin.com/in/learningpoint-ninety-two-8b8008159/">linkedin</a>
<a href="https://www.youtube.com/watch?v=qKK53r6CCgU">Youtube</a>
inclu.php
<?php include("Lp.html"); ?>
< h2> Welcome To LearningPoint92</h2>
Output:
Home | Blog | Facebook | twitter | linkedin | Youtube
Welcome To LearningPoint92
require File
require file is used to include the PHP, HTML, or text on multiple pages of a website.
It is similar to include file.
require file is used to include the PHP, HTML, or text on multiple pages of a website.
It is similar to include file.
You can insert the content of one PHP file into another PHP file (before the server executes it) with the require statement. That means you can reuse the code again and again
It
includes a specified file. It will produce a fatal error if it fail to find the
file and stops the execution
Syntax:
require
'filename';
Example:
Lp.html
<a
href="#">Home</a> |
<a
href=" https://learningpoint92.blogspot.in/">Blog</a> |
<a
href="
https://www.facebook.com/LearningPoint92/">Facebook</a> |
<a
href=" https://twitter.com/LearningPoint92">twitter</a>
|
<ahref="https://www.linkedin.com/in/learningpoint-ninety-two-8b8008159/">linkedin</a> |
<a
href="https://www.youtube.com/watch?v=qKK53r6CCgU">Youtube</a>
requ.php
<?php require("Lp.html"); ?>
< h2> Welcome To LearningPoint92</h2>
Output:
Home | Blog | Facebook | twitter | linkedin | Youtube
Welcome To LearningPoint92
Note:
Note:
include_once()
It
includes a specified file. a file has already been included, it will not be
included again. It will produce a warning if it fail to find the file and
execute the remaining scripts.
require_once()
It
includes a specified file. a file has already been included, it will not be
included again. It will produce a a fatal error if it fail to find the file and
stops the execution
No comments:
Post a Comment