PHP Include
PHP Include
PHP allows
us to create various elements and functions, which are used several times in
many pages. It takes much time to script these functions in multiple pages.
Therefore, use the concept of file
inclusion that helps to include files in various programs
and saves the effort of writing code multiple times.
"PHP
allows you to include file so that a page content can be reused many times. It
is very helpful to include files when you want to apply the same HTML or PHP
code to multiple pages of a website.
Advantage
Code
Reusability: By the help of include and require construct, we can
reuse HTML code or PHP script in many PHP scripts.
Example:
namespace.php
<?php
namespace kbn;
Class exe
{
function display()
{
echo “display</br>”;
echo __namespace__;
}
function getdata()
{
Echo
“<br> getdata”;
}
}
$a=new exe;
$a->display();
$a->getdata();
?>
include.php
<?php
include “namespace.php”;
$a=new kbn/exe;
$a->display();
?>
Comments
Post a Comment