0

Hi peeps

I wonder if someone can tell me about having includes inside of includes.

Basically I have a $code_block =. "some small content"

but inside this small content, I need to refer to another include, something like this:

"page.php"

if (...){
    $display_block = "text text";
}else{
    include('../code_block.php');
    $display_block = $code_block;
}

then
code_block.php

html html...
but here i need an include[/COLOR]
 html html... 
and here i need an include 
 html html... 

So to recap I need to call an include inside an include?

Edited by Nick Evan: Fixed formatting

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by vibhaJ
0

So I believe I have figured this out....

for the html I wish to include in the include
I set it to a

$var (.)= "<div's ... </div>" called bit_with_var.php

then the important bit is call it here

if (...){
    $display_block = "text text";
}else{
    include('../bit_with_var.php');
    include('../code_block.php');
    $display_block = $code_block; <----------------($... = $var will be inside this)
}

then I can use it here

$display_block = "<div seperate> (an inner div ends in last disp block)
";

$display_block .= $var; (a menu)

$display_block .= "<div><div>
</div></div></div>";

Little bit of a chicken and the egg, all very confusing but hopefully it might help someone and I know I sure wont forget this. I think the key to this is that the:
(1) include content is set to a $var in its own .php,
(2) then the include .php is called in the main php page,
(2) but the echo or $disp_block .= $var is in the intermediary block.

....just contact me if you find this - if I can help more I will

most importantly I have done this with 0 error clean validating html

Edited by Nick Evan: Fixed formatting

0

1) If code_block.php is in parent folder then only use include('../code_block.php') if both files are at same folder then use include('code_block.php')
2) You need to create $code_block variable in code_block.php in order to use it in page.php

<? $code_block = 'html html...
    but here i need an include
    html html...
    and here i need an include
    html html...';
    ?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.