#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    PK,CN
    Posts
    4
    Rep Power
    0
    I write a script news.php calls a function head() in predefine.php,which include a head.html file.
    the problem is when I call function head(),I always get include path error,I found out that $DOCUMENT_ROOT is NULL,but I use phpinfo() got the correct value.
    Can somebody tell me why?
    I use PHP4.0.1pl2 on RedHad 6.1 with apache 1.3.12 static .

    sorry for my poor english
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4476
    Can you explain the layout of the files a little more? This is how I interpret your question...

    ***predefine.php***
    function head()
    {
    include("head.html");
    }

    ***news.php***
    include("predefine.php");
    head();

    If you're calling it just like that and everything is in the same directory, then it should work. I can't see a problem. $DOCUMENT_ROOT is goign to be null within the head() function because it's a function. You'd have to declare the variable as global, or pass it along if you want to use it in a function.

    Maybe you can explain a little more if you are still having trouble.

    ---John Holmes...
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    PK,CN
    Posts
    4
    Rep Power
    0
    Yes , it is.
    thanks,I got it.

    I am amazed that phpinfo() in head() got the correct value.

    I can go round it by assign another variable before I call head().

    thanks

Similar Threads

  1. N00bert question
    By ponloeu in forum C Programming
    Replies: 2
    Last Post: February 2nd, 2004, 09:11 PM
  2. the linker, the include and interdependent classes
    By behco in forum C Programming
    Replies: 7
    Last Post: February 1st, 2004, 07:55 AM
  3. the linker, the include and interdependent classes
    By behco in forum C Programming
    Replies: 0
    Last Post: January 31st, 2004, 12:57 PM
  4. Direct Music Initialization Problem
    By jonnathan in forum C Programming
    Replies: 0
    Last Post: January 26th, 2004, 04:29 PM
  5. Your thoughts on include()
    By JessJenn in forum PHP Development
    Replies: 4
    Last Post: January 25th, 2004, 05:51 PM

IMN logo majestic logo threadwatch logo seochat tools logo