SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Hybrid View

  1. #1
    SitePoint Zealot websalacarta's Avatar
    Join Date
    May 2003
    Location
    Spain
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $DOCUMENT_ROOT doesn´t work in a require_once

    Hi, I don´t understand what´s happening here... any indea?


    Code:
    echo ($DOCUMENT_ROOT);
    require_once('lib/pictures.php');

    lib/picture.php
    Code:
    echo ($DOCUMENT_ROOT);

    first $DOCUMENT_ROOT works, but the one in the lib/picture doesn´t
    why $DOCUMENT_ROOT in lib/picture.php doesn´t work?
    thanks

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so your on ensim?
    Michael D'Angelo
    mdangelo@mdangelo.com
    Free Link Popularity, www.expirednic.com
    Macintosh Webmaster Information, www.webmastermac.com

  3. #3
    SitePoint Zealot websalacarta's Avatar
    Join Date
    May 2003
    Location
    Spain
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don´t know, I´m using a shared hosting, what does "ensim" mean?



    Quote Originally Posted by mdangelo
    so your on ensim?

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ensim I believe is the name of your hosting control panel software. $DOCUMENT_ROOT as far as i know is an ensim defined variable.

    Anyway why are you using that- or am I wrong and it happens to be one you defined somewhere??
    Michael D'Angelo
    mdangelo@mdangelo.com
    Free Link Popularity, www.expirednic.com
    Macintosh Webmaster Information, www.webmastermac.com

  5. #5
    SitePoint Zealot websalacarta's Avatar
    Join Date
    May 2003
    Location
    Spain
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My control panel is cpanel

    I thougth $DOCUMENT_ROOT was a php environment constant

    I want to use it because I want my code to be portable when I change the server and/or the folder

    Thanks

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Netherlands
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you mean:

    $_SERVER['DOCUMENT_ROOT'];

    $DOCUMENT_ROOT is actually not a predefined PHP variable.

  7. #7
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah - $DOCUMENT_ROOT I think is one that works on ensim from what I recall. But yeah I wasnt thinking about the one that atrix mentioned.

    Take care.
    Michael D'Angelo
    mdangelo@mdangelo.com
    Free Link Popularity, www.expirednic.com
    Macintosh Webmaster Information, www.webmastermac.com

  8. #8
    SitePoint Zealot websalacarta's Avatar
    Join Date
    May 2003
    Location
    Spain
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh dear!

    I always have the same mistake...

    thanks very much for your help

  9. #9
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    referencing things by /var/www/html* and stuff like that tends to be agood when working with php and such becqause most hosting platforms work that way.


    Portability is always of concern.
    Michael D'Angelo
    mdangelo@mdangelo.com
    Free Link Popularity, www.expirednic.com
    Macintosh Webmaster Information, www.webmastermac.com

  10. #10
    Team SitePoint Lucas Chan's Avatar
    Join Date
    Sep 2002
    Location
    Melbourne
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mdangelo
    referencing things by /var/www/html* and stuff like that tends to be agood when working with php and such becqause most hosting platforms work that way.

    Portability is always of concern.
    Hard coding '/var/www/html' into your files is usually not a good thing to do.

    I would suggest using $_SERVER["DOCUMENT_ROOT"]. This will be especially helpful if you write your code on a development server and later deploy it to a production server.

    If you absolutely must hard code a path, try to make life easier for yourself by defining it only once in some sort of configuration file that's included on each page. Having to change paths in 50 PHP files is not cool.


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
  •