Php include function

PHP Include@ Shwetank education.com

  PHP Include Function
Creating a PHP Include file will allow you to easily update all your pages from one file.

Features Of Include Function

1.Update different parts of your site from one file.
2. Include content from other web sites outside your server(not possible with SSI).
3.You can include files with .php, .html,txt and other extensions.

Include Function Example
First we create a file which will be included later and it only contains a variable initialisation:
welcome.php
<?php
$name = Shwetank;
?>
After this we create an other file which is the main file and it will include the welcome.php as follows:
test.php
<?php
echo “Value of name before include is: $name
“;
include(“welcome.php”);
echo “Value of name after include is: $name
“;
?>

Output:
Value of name after include is
Value of name after include is:shwetank

Note*-included file are missing then show warning message

Other One
include_once()
// only one time use in one page .
require () //same work in include (), but file are missing then fatal error message
require_once //only one time use in one page .