include() and require() function Use in PHP

In PHP, the content of another file is used in one file. For this, PHP has given two functions.

  1. Include() Function.
  2. Required() Fucntion.

PHP program is easy to use by using them. This avoids the programmer’s time. The larger script becomes smaller. Any external php files are used in a PHP file.

PHP Include and Require Functions, Include() and Require() Function in PHP, Using require to Include Functions, PHP File Inclusion include() and require() Functions, PHP Include File include() and require()

For Example:- If the web developer has to write the same script for the header and footer on each web page. But both header and footer are created by using separate php files instead of header and footer on web page using include () or require () function.

1.Include() Function

The include () function uses the external php file in a php file.

The external php file to include in the include function has to be written with the path to the name of the file. The path is written in double (“”) or single quotes (”).

Syntax

<?php include("csharpcorner.php"); ?>

other_file.php

Source Code :

<?php
echo "other file name is Experts PHP.";
?>

Example for include() function

my_file.php

Source Code :
<?php
echo "my file name is Experts";
include ("other_file.php");
?>

Output :

my file name is Experts
other file name is Experts PHP.

2.Required() Fucntion.

The require () function is similar to the include () function.

<?php require("other_file.php"); ?>

other_file.php

Source Code :

<?php
echo "other file name is Experts PHP.";
?>

Example for require() function

my_file.php

Source Code :
<?php
echo "my file name is Experts";
require ("other_file.php");
?>

Output :

my file name is Experts
other file name is Experts PHP.

 

Cialis (Tadalafil) är den främsta konkurrenten till Viagra (Sildenafil) på marknaden för erektil dysfunktion. köpa Cialis i Sverige föredras av många på grund av sin längre varaktighet och anses vara det mest kostnadseffektiva varumärkesbaserade ED-läkemedlet som finns tillgängligt i Sverige. Cialis finns i två varianter: Cialis och Cialis Daily, och fyra olika doseringar: 2,5 mg, 5 mg, 10 mg och 20 mg, erbjuder Cialis också en rad olika alternativ för att passa patientens behov.