php-mysql tutorial

Designed By NISHANT GUPTA

  • Home
  • PHP
  • HTML
  • CSS
  • JavaScript
  • JQuery
  • Contact-us
  • Learn HTML

    • Introduction of HTML
    • Image Handling in HTML
    • List Handling in HTML
    • Font Handling in HTML
    • Table Handling in HTML
    • Form Handling in HTML
  • Learn CSS

    • Introduction of CSS
    • Styling Background in CSS
    • Styling Text in CSS
    • Styling Font in CSS
    • Styling Link in CSS
    • Styling List in CSS
    • Styling Table in CSS
    • Styling Div in CSS
    • Styling Span in CSS
    • Positioning in CSS
    • Display in CSS
  • Learn JavaScript

    • Introduction of JavaScript
    • Data Type in JavaScript
    • Variable in JavaScript
    • Oprator in JavaScript
    • Cond. Statement in JavaScript
    • Loop in JavaScript
    • Array in JavaScript
    • Function in JavaScript
    • Date in JavaScript
    • String in JavaScript
    • DOM in JavaScript
    • Event Handling in JavaScript
    • Form Handling in JavaScript
  • Learn PHP-MYSQL

    • Introduction of PHP
    • Decision Control in PHP
    • Loop in PHP
    • Array in PHP
    • Function in PHP
    • Form Handling in PHP
    • File Inclusion in PHP

File Inclusion in PHP

Introduction

  1. Being able to include other files into our PHP scripts, is a useful thing.
  2. The include( ) function allows us do this.
  3. Suppose we have a text file that we want to include in a web page that we've already got up and running.
  4. We could copy and paste the text from the file straight into our HTML. Or we could use the include( ) function
  5. Including files saves a lot of work.
  6. This means that we can create a standard header, footer, or menu file for all our web pages. Then, when the header needs to be updated, we can only update the header include file.
Syntax

<?php

include ('filename‘);

?>

Example

index.php

<?php

  print "This is the original content<br>";

  include (“secpage.php");

?>

Example

secpage.php

<?php

  print "This is from second page";

?>

Output

Upon executing index.php, we'll get the following output:

This is the original content

This is from second page

This is because, to the web server, it sees the following content:

<?php

  print "This is the original content<br>";

  print "This is from second page";

?>

Advertisements

 

©  2014 All Rights Reserved  •  Design by >Nishant Gupta.

Privacy Policy • Terms of Use