Q: file path in php includes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NoPeasHear
    New Member
    • Aug 2006
    • 22

    #1

    Q: file path in php includes

    How do I make the following work? I tried a few different versions, and I can't seem to quiet get it right. I am trying to create a universal php include.

    Changing this:
    [PHP]
    <?php include("menu.p hp"); ?>
    [/PHP]

    to something like this....
    [PHP]
    <?php include("www.ho mepagehere.com/includes/menu.php"); ?>
    [/PHP]
  • TheMadMidget
    New Member
    • Oct 2006
    • 98

    #2
    PHP is server side so you can't put the web address in but you can base it off of the root server folder in this way:
    [PHP]
    <?php include("/includes/menu.php"); ?>
    [/PHP]

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      I am sorry to disappoint you, theMadMidget, but you can. Try this test. Store on your server and run A.PHP.
      [php]
      A.PHP:
      <?php
      include ('http://www.mysite.com/b.php');
      include ('c.php');
      ?>

      B.PHP:
      <?php
      echo 'This is B.PHP<br>';
      ?>

      C.PHP:
      <?php
      echo 'And this is C.PHP<br>';
      ?>[/php]

      Ronald :cool:

      Comment

      • TheMadMidget
        New Member
        • Oct 2006
        • 98

        #4
        What kind of system are you using ronverdonk, because I have PHP 4 on Unix and that doesn't work?
        Last edited by TheMadMidget; Nov 26 '06, 06:05 AM. Reason: Misspelling

        Comment

        • ctsasikumar
          New Member
          • Nov 2006
          • 17

          #5
          Originally posted by TheMadMidget
          What kind of system are you using ronverdonk, because I have PHP 4 on Unix and that doesn't work?
          Hey

          i think this is bestwy
          $root=$_SERVER['DOCUMENT_ROOT'];
          $path=$root."/include/filename.php";
          include($path);

          Comment

          Working...