Setting relative path in class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chathura86
    New Member
    • May 2007
    • 227

    Setting relative path in class

    i have created some php classes in deferent folders which requires each other
    i have given relative paths relative to those files

    i used require_once()

    but when i use those class in a file outside the class folder i get a error
    message stating that the path is incorrect

    i seems like path is setting relative to the page im using those classes not relative
    to the class which is requiring it.

    please help me

    thank you
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    you can use './' to go to the directory in which the inital include started.

    Comment

    • chathura86
      New Member
      • May 2007
      • 227

      #3
      is there any way to specify the root folder

      so i can generate the relative paths from the root

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Heya, Chathura.

        Try something like this:

        [code=php]
        require_once "{$_SERVER['DOCUMENT_ROOT']}/path/to/include/file.php";
        [/code]

        Comment

        • chathura86
          New Member
          • May 2007
          • 227

          #5
          it works

          thank you very much

          chathura bamunusinghe

          Comment

          Working...