How to get the URL of the php script being called?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ernest Kim

    How to get the URL of the php script being called?


    Is there a way to get the URL of the php script being called? For
    example, in my web browser I goto the URL:
    "http://www.foo.com/foo.php", how do I print out
    "http://www.foo.com/foo.php" in the foo.php script? Is it stored in a
    variable some where? I'd like to do this for error handling for some
    functions I'm writing.

    -Ernie
  • Joshua Ghiloni

    #2
    Re: How to get the URL of the php script being called?

    Ernest Kim wrote:[color=blue]
    > Is there a way to get the URL of the php script being called? For
    > example, in my web browser I goto the URL:
    > "http://www.foo.com/foo.php", how do I print out
    > "http://www.foo.com/foo.php" in the foo.php script? Is it stored in a
    > variable some where? I'd like to do this for error handling for some
    > functions I'm writing.
    >
    > -Ernie[/color]
    $_SERVER['PHP_SELF']

    Comment

    • news

      #3
      Re: How to get the URL of the php script being called?

      "Ernest Kim" <krazykid@big-bird.bu.edu> wrote in message
      news:wbey8z7if6 m.fsf@big-bird.bu.edu...[color=blue]
      >
      > Is there a way to get the URL of the php script being called? For
      > example, in my web browser I goto the URL:
      > "http://www.foo.com/foo.php", how do I print out
      > "http://www.foo.com/foo.php" in the foo.php script? Is it stored in a
      > variable some where? I'd like to do this for error handling for some
      > functions I'm writing.
      >
      > -Ernie[/color]

      "http://".$_SERVER['HTTP_HOST'].$_SERVER[PHP_SELF];


      Comment

      • C G W

        #4
        Re: How to get the URL of the php script being called?

        "Ernest Kim" <krazykid@big-bird.bu.edu> wrote in message
        news:wbey8z7if6 m.fsf@big-bird.bu.edu...[color=blue]
        >
        > Is there a way to get the URL of the php script being called? For
        > example, in my web browser I goto the URL:
        > "http://www.foo.com/foo.php", how do I print out
        > "http://www.foo.com/foo.php" in the foo.php script? Is it stored in a
        > variable some where? I'd like to do this for error handling for some
        > functions I'm writing.[/color]

        Try this:

        $file_name = substr(strrchr( $PHP_SELF, "/"), 1);
        $file_name would be 'foo.php'

        Hope this helps

        Chris.

        --
        C G W
        chris.g.woodNS@ btinternet.com



        Comment

        Working...