include()

Discussion in 'PHP' started by szf, Jul 13, 2008.

  1. #1
    hello all,
    i am new to php programming. i want to send the name of the current page to the php page being included using include().
    can anyone please help me??? :confused:
     
    szf, Jul 13, 2008 IP
  2. revvi

    revvi Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    could you describe more on what you want? I'm not really clear on your questions :)
     
    revvi, Jul 13, 2008 IP
  3. seo8k

    seo8k Guest

    Messages:
    70
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    include("ThePageWantBeIncluded.php");
    any more questions? u can pm me
     
    seo8k, Jul 13, 2008 IP
  4. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #4
    Are you asking that the page your including to save the name as a variable to only allow traffic comming from a certain page for security? or affiliate type stuff?

    or am I way off?
     
    mokimofiki, Jul 14, 2008 IP
  5. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #5
    I think he is asking us:

    How to let the included page know about the page which is including it.
    or simpler: how to let the child page(included page) know who the parent is (the page making the include() call)

    If yes, try the below:

    The parent file, which is including another file, lets call the included file as 'child.php'
    
    <?php
    include('child.php');
    ?>
    
    PHP:
    Now, the 'child.php'
    
    <?php
    $parent=$_SERVER['REQUEST_URI'];
    echo 'This file was included by '.$parent;
    // will output: This file was included by /parent.php
    ?>
    
    PHP:
     
    rohan_shenoy, Jul 14, 2008 IP
  6. szf

    szf Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanx Rohan :)
     
    szf, Jul 19, 2008 IP