Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts

    Question Echo URL where PHP 'include' located

    I've several pages I want logged. I had the entire PHP script on each page with the name of the page in the script (echo <div>Page: Index</div>, echo <div>Page: Email</div>, etc). Now I've put the script as its own .php page and have installed <?php include("php/logging.php"); ?> on all the pages I want to log.

    The problem now is I have no idea which pages the logs are coming from. So I was thinking that I could just echo the URL of the page being logged at that time.

    I know it's possible to document.write the URL with JS, but can it be done just PHP? I also thought about trying to echo the page title as well, but I dont know if that's even possible with PHP.

    <div> - putting your mind in a box since 1997

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    You have a few options, something in the $_SERVER superglobal should suffice. Run this script and see some results:
    PHP Code:
    <?php

    foreach($_SERVER as $elm => $value)
    {
        echo 
    $elm ' - ' $value "<br>";
    }

    ?>
    ref:
    http://us2.php.net/reserved.variables

  • #3
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts

    Question

    *edited*

    Got it.

    Thank you!
    Last edited by ArcticFox; 01-24-2007 at 09:58 PM.
    <div> - putting your mind in a box since 1997


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •