Question:

PHP question. Program-wise, how can I extract the URL address of the website my program is currently reading?

by  |  earlier

0 LIKES UnLike

I have a URL that will bring me to another URL, and I need to extract the final URL from the final webpage.

 Tags:

   Report

2 ANSWERS


  1. <?

    echo $_SERVER['HTTP_HOST'];

    ?>

    That will spit out:

    www.mydomain.com

    This might help.  This will spit out all the SERVER variables.  You might find one usefull:

    $out = print_r($_SESSION, true);

    $out = str_replace("\n", "<br>", $out);

    $out = str_replace(' ', " ", $out);

    print $out;


  2. Show us some of your code, that way we may better help you.

    You have a "URL" which brings you to another "URL". Indeed, do you even know what a URL is?

    Why don't you just echo the variable containing the URL? I.E.

    -----StartCode-----

    <?php

    echo '<p>' . $_SERVER['HTTP_HOST'] . '</p>';

    ?>

    -----CodeEnd-----

    If the URL is submitted through a form, it is likely that you can access it through the $_post or $_get variables. I.E.

    -----StartCode-----

    <?php

    echo '<p>' . $_post['NAME'] . '</p>';

    ?>

    -----CodeEnd-----

    The "NAME" would refer to the name attribute of the form input element.

    See also: http://php.net/reserved.variables - Predefined variables

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.