Monday, April 30, 2012

PHP Include Function Tutorial


Include Function
Let's say we want to put hundred different web pages. Bunch of time, going to webpage to webpage and updating each one, one by one, with include function.
menu.php
<html>
     <head>
    </head>
 <body>

      <ul>
     <li>Home </li>
     <li>HTML</li>
     <li>PHP </li>
     </ul>

</body>
</html>
Output
  • Home
  • HTML
  • PHP

You need very time to display the above output in your every web page.
Just use include key word and file name that you attach.
first.php
<?php
include 'menu.php';
<p> This is first page <p/>
?>

second.php
<?php
include 'menu.php';
<p> This is second page <p/>
?>

You need not open menu.php file.
When you open first.php file and second.php file, menu.php file will automatically open each time. Need not require write extra code for menu. Include acts like function call.

No comments:

Post a Comment