SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: $_server

  1. #1
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    philmont
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_server

    ok, so I'm looking at using the $_SERVER function to help with my links/includes.

    I can manage to do this successfully::
    <?php
    echo "www." . $_SERVER['HTTP_HOST'] . "/example/test.php";
    ?>
    and it will show this::
    however, I'd like to make this into an include instead?
    How do I make this into a link?

  2. #2
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Include or link ? not the same thing. I suspect you mean a link
    PHP Code:
     
    echo '<a href="www. ' $_SERVER['HTTP_HOST'] . '/example/test.php"> This link </a>'
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  3. #3
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    philmont
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know they arent the same thing- I was planning on using it for 2 different functions....


    I have a bunch of includes, one of which is a menu. Unfortunately this menu relies on being included on a base directory. If the page I have is in the 3nd level (domain.com/1st/2nd/3rd.php) and wanted something from the base level domain.com....how would I go about getting to it without using ../../example.com?

    Im not sure if I explained this well. Basically I want to get away from using the ../../../etc.php to get to my includes from another directory and instead just use the $_server function to say domain.com/x.php

    EDIT:: the link version gives me the www.domain.com/www.domain.com/example/test.php

    how do I resolve this to without the double domain

  4. #4
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Sorry, thought you wanted links.

    You can set the path(s) where the include statements looks for files in with include_path http://fr.php.net/manual/en/ini.core...i.include-path

    Sorry (again) forgot the http:// in the link
    PHP Code:
    echo '<a href="http://www.' $_SERVER['HTTP_HOST'] . '/example/test.php"> This link </a>'
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming


Bookmarks

Posting Permissions

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