Http_referer

Discussion in 'PHP' started by Hyphen, Dec 22, 2008.

  1. #1
    I am trying to set a variable based on HTTP_REFERER... but for example, if the page I was at right now when posting this topic detected my referer, it'd show as
    http://forums.digitalpoint.com/newthread.php?do=newthread&f=37
    Code (markup):
    Is there a way I can manipulate the string to cut off at
    http://forums.digitalpoint.com
    Code (markup):
    to use as easy as it is to use simply...
    $site = $_SERVER['HTTP_REFERER'];
    Code (markup):


    I don't know if this is a matter of using 'strpos' or what.
     
    Hyphen, Dec 22, 2008 IP
  2. maneetpuri

    maneetpuri Active Member

    Messages:
    152
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Hi,

    What you may do is –

    Find the first occurrence of “/” starting from the 8th position of the string in HTTP_Referrer

    Then get a sub string starting from beginning of the string till the position retuned above, this will give you what you want.

    Hope this makes sense to you.

    Cheers,

    ~Maneet
     
    maneetpuri, Dec 23, 2008 IP
  3. mallorcahp

    mallorcahp Peon

    Messages:
    141
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    might want to try parse_url :

    also $info['scheme'] will give you the "http" bit ... you would need to add the "://" ... or you could just add "http://" ...
     
    mallorcahp, Dec 23, 2008 IP
  4. Jackboy

    Jackboy Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    explode(); could be used :)
     
    Jackboy, Dec 24, 2008 IP