Jump to content

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";
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.