Sharp Tutorial
include in php

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

PHP Introduction

  • PHP home
  • PHP introduction
  • How to install and run
  • Syntax and Rule in PHP
  • Data type and operator
  • If else in php
  • Loop in php
  • Array in php
  • Sring in php
  • Function in php
  • Include in php

Working with Forms

  • Get and Post
  • Get Form input into PHP
  • Form Validation

PHP with MySQl

  • Connect PHP & Mysql
  • Insert using PHP Mysql
  • Select using PHP MySql
  • Delete Update using PHP Mysql
  • Login Page Example in PHP

Advanced PHP

  • Session in PHP
  • Cookies in PHP
  • File Handling in PHP
  • File Upload/Download PH

Object Oriented PHP

  • Class Obejct in PHP
  • Constructor in PHP
  • Destructor in PHP
  • Inheritance in PHP

include in PHP

When we want same code to repeat on other pages that we can add that page using include or require. The difference between them is that include ignore with warning if include file not found while require throws an error.

How to use include and require a php page using include.

<?php include 'includefile.php';

 <?php require ‘noFileExists.php’;

// header.php
<?php
echo "header output";
?>
//mainpage.php
<?php include 'header.php' ?>
<?php
echo " body part of the main page";
?>

output of the above both pages is . it does not give error even if header is not present.

header part

body part of the main page. 

//mainpage.php
<?php require 'noFileExists.php';
<?php
echo " body part of the main page";
?>

 

 

if header.php is available it gives the same output but if header not there it gives the error

Above query Displays the all records (with all headings) . as following.

Enquiry about Course

Ask your Question

Click Here

Sharp (2) Tutorials

Video/ C Introduction

Watch video in full size

Video tutorial

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial