SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Thread: $_server

  1. #1
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_server

    Hi,

    What is actually the difference between

    $_SERVER['HTTP_HOST']

    and

    $_SERVER['SERVER_NAME']

    ???
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  2. #2
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi :-),

    >> $_SERVER['HTTP_HOST']
    The http_host variable contains the value of the host field in the http header:

    Example of an http request:
    Code:
    GET /path/to/page.php HTTP/1.1
    host: example.net
    in this example $_SERVER['HTTP_HOST'] will contain ``example.net''

    more infos @
    http://www.w3.org/Protocols/rfc2616/....html#sec14.23

    >> $_SERVER['SERVER_NAME']
    Is the host name of server set into httpd.conf.
    When using virtual hosts ( ie multiple domains on the same server ) it's compared to the ``host'' value.
    It's also used when making external redirections, if hostnamelookup directive is set to off.
    http://httpd.apache.org/docs/mod/core.html#servername

    A considerations:

    ServerName example.net
    ServerAlias *.example.net

    request -->> www.example.net/path/to/something.html

    if you force an external redirection (301, for example)...the URI will be:
    example.net/path/to/redirected/file.html

    and not to
    www.example.net/path/to/redirected/file.html

    that's because apache will use the value of the servername which does not contain the www part :-)

    Hope It Helped.

    Thank you,
    :-) Andrea
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  3. #3
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  4. #4
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmmm, started reading more, and have become more confused. Basically I'm using includes to add files, the thing is I don;t yet know what the domain is going to be, probably: writhlington.bathnes.sch.uk

    What is the best method of ensuring i get the correct domain name for the includes, i.e.

    include($domainpath."\somefolder\somefile.php");

    ???
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  5. #5
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why don't you just include locally? example:
    include('/home/user/file.php');
    instead of using full url ?
    - website

  6. #6
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    because I don't know what the full thing will be locally. This site is going to have thousands of pages, which can be sumitted by users, the userse also have ability to create folders, etc. When they upload files then this will be prepended:

    <?php
    include($blah);
    ?>

    howver because I don;t know where it;s going to be hosted (swears at management) i donlt know the full path. My other idea was to stick a file in each direcrtory called inc.php with the oath to the files to include then you just go:

    <?php
    include("inc.php");
    ?>

    That way I only have to alter the inc.php files???
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  7. #7
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could define a constant in your script and you would always place it before including, then you would only need to change that in one place.
    - website

  8. #8
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    then you would only need to change that in one place.
    But with hundreds of pages, that would have to be updated in everypage! and of course I can't include that from a single file else where because I don't know the full path! (head starts to hurt)
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  9. #9
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But you do know how all the files will be according to each other ?
    I mean, say you have 2 files
    /home/user/file1.php
    /home/user/misc/file2.php
    Even if you don't know what 'user' might be you do know that from file1.php file2.php is misc/file2.php right ?

    Else you are in total mess :|
    - website

  10. #10
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Else you are in total mess :|


    yeah realtional URLs, harder to implement, but yeah y not.
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  11. #11
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    or you have a single include, which you locate using ../../ or whatever, and from that file you include everything from it.

    example:

    file /var/www/html/something/index.php

    PHP Code:
    include_once('../include.php'); 
    file /var/www/html/include.php:

    PHP Code:
    $include_path dirname(__FILE__);
    include_once(
    $include_path '/include/class.php');
    include_once(
    $include_path '/include/funct.php');
    include_once(
    $include_path '/include/login.php'); 
    then you only need to worry about making you you properly call that include.php file properly, and all of your other includes get included.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  12. #12
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but that might include lot of unneccisary stuff...
    - website

  13. #13
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so you set an array of the required elments, before you include it, then check them.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.


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
  •