Jump to content

[SOLVED] How To Use Include For Another Sub-Directory?


phpQuestioner

Recommended Posts

I want to be able to use a include from one sub-directory; to add to a page in another sub-directory, but I am having problem getting it to display. I tried to do like the manual said, but for some reason; it does not seem to be working (it does not display anything at all). Any one got any idea why not? Code Below.........

 

<?php

// this would be number.php page from sub-directory1

$mynumber="000-000-0000";

?>

 

<?php

// this would be the page in sub-directory2

include 'http://www.domain.com/sub-directory1/number.php';

echo "$mynumber";
?>

Nope.

 

Say you have something like this:

 

Folder1

    number.php

 

Folder2

    index.php

 

To include number.php in index.php you'd put something like include_once "../Folder1/number.php";

 

The 2 dots say go up a level and then look for Folder1.

   

Well my folder layout is something like this:

 

-Domain

  - Sub 1

    - Folder 1 (page to include here)

    - Folder 2 (page I want include in here)

 

 

Folder 1 & Folder 2 are in the same level.

 

So how would the include work this way or will it not work at all this way?

 

Would you just do this:

 

<?php

include_once("Folder1/number.php");

echo "mynumber";

?>

there is two sub-directories in one sub-directory (the hierarchy is just as I have it in the example i have [iurl=http://www.phpfreaks.com/forums/index.php/topic,154076.msg666865.html#msg666865]here[/iurl]). one of these two sub-directories contain the php file to include and the other sub-directory contains the php file I want the include to be put in.

 

ok, tried it like you said; but it's still not there.

 

<?php
include_once("..Folder1/number.php");
echo "$mynumber";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.