MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

PHP Programing language

File Inclusion in PHP
Previous Home Next

File Inclusion

In PHP, the content of php file include to another php file before the server execution. It help to create elements, functions, header or footers etc that can used again and again in multiple pages. If any changes are required then only included file changed this makes easier to the developer.

There are two functions that are used to include a file:
  1. The include() Function
  2. The require() Function

Include() Function: You can include the content of one PHP file into another PHP file. It only produce a warning (E_WARNING) and the script will continue. Including files is very useful when you want to include the same PHP, HTML, or text on multiple pages of a website.

Example:

 

test.php code:

<html>
<head><title>Include() in Php</title>
</head>
<body bgcolor="#FFFF99">
<?php 
include("abc.php");
?>
<p> Other content of the file</p>
</body>
</html>
abc.php code:

<a href="http://r4r.co.in/">Home<br/></a>
<a href="http://r4r.co.in/profile/index.shtml">About Us<br/></a>
<a href="http://r4r.co.in/profile/careers.shtml">Careers<br/></a>
<a href="http://r4r.co.in/profile/contact_us.shtml">Contact Us</a>

Output:

Require() Function: It takes all the text/code/markup that exists in the specified file and copies it into the file that uses the include statement. It will produce a fatal error (E_COMPILE_ERROR) and stop the script.

Example:

test.php code:

<html>
<head><title>Require() in Php</title>
</head>
<body  bgcolor="#FFCCFF">
<?php 
require("abc.php");
?>
<p> Other content of the file</p>
</body>
</html>
abc.php code:

<a href="http://r4r.co.in/">Home<br/></a>
<a href="http://r4r.co.in/profile/index.shtml">About Us<br/></a>
<a href="http://r4r.co.in/profile/careers.shtml">Careers<br/></a>
<a href="http://r4r.co.in/profile/contact_us.shtml">Contact Us</a>

Output:

Previous Home Next