Page 1 of 1

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

Posted: Sat Apr 10, 2004 2:49 am
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

Posted: Sat Apr 10, 2004 3:56 am
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

Posted: Sat Apr 10, 2004 5:31 am
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

Posted: Sat Apr 10, 2004 9:38 am
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