including inside an include file? (or, embedded includes)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

including inside an include file? (or, embedded includes)

Post by robster »

Hi :)

This is interesting.

I have three files. file1.php is at the root level, file2.php is included inside file1.php and file3.php needs to be included inside file2.php.


Is this possible because it appears that the last include (the include in an include) is not working.

Thanks a TONNE for your help :)

Rob
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

test1.php

Code: Select all

<?php
include("test2.php");
?>
test2.php

Code: Select all

<?php
include("test3.php");
?>
test3.php

Code: Select all

<?php
print("Working !");
?>

http://localhost/test1.php
Working !

Looks like inner includes works well
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

The only problem you could run into is the one with relative paths..

p1 include ../foo/p2


p2 include ../../../bar/p3


Does p2 include relative to p1 or relative to p2? :)
The answer is at http://be2.php.net/manual/en/function.include.php
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

Actually I'm so sorry, it was a simple spelling mistake in my filename!!!

But it was very interesting non the less to see about that path thing! Thanks so much you two :)


Rob
Post Reply