Friday 22 April 2011

External Links In PHP




External Links

Include: by using this concept we can include a php script in another php script. Once we include the php script we can access the executable statements, functions, variables, consistence, and classes.
*Include embeds external script in the current executable script. We can embed the external script multiple times. If the external link is not available this function retuns a warning massage and executes the statement.
EX:
Page1.php
<?php
error_reporting(E_ALL);
echo "frompage1";
include "page2.php";
echo $x;
$x=200;
echo $x;
echo constant ("city");
fun1();
?>
*save this file in htdocs as “page1.php”

Page2.php
<?php
echo "page2";
$x=100;
define ("city","hyd");
function fun1()
{
echo "from page2";
}
?>
*save this file as “page2.php” and open the browser and type http://localhost/page1.php
Include_once: By using this function we can embed the external file only one time.
'
Require: This function embeds external file multiple times. If the external file in not available it returns fatal error and stops the execution of the script.

Require_once: It is same as require but, it can embed the external links only one time.

2 comments:

  1. Dear Sir, I am sai chowdhary i have completed my php courese 9am to 7am Batch. Give me some good suggestion for future. I m looking for a job as a fresher U can send me any query to saibaba.c@gmail.com Thanking You sai

    ReplyDelete
  2. sir good evening this is karunakar ,present jquery class run any batch please give information

    ReplyDelete