grubstuck-
the examples given to you are valid ways to accomplish what your trying to do.
your trying to have part of a single statement span mutiple files. you cant do that, you have to split the statements up into equivalent peices, that each contain a complete statement.
there is a way you could make what your doing work though. you would have the read all you include files into a string(using file_get_contents() for example), and then, evaluate the php using eval() instead of using include()
that way you kinda "compile" the _entire_ statement into a string before php starts evaluating it. but i would not recomend using eval. usually, if you need to use eval() to solve your problem, your design could benefit greatly by improving it.
i would recomend you take a long hard look at your design and see how you could restructure and improve it.
i still think my second example is exactly what your after, i just dont think you realize it yet.
all you really want is an if{} else{} statement. you can acheive the exact same functionality of that by using 2 if{} statements, just negating the condition in the second if statement, like i have done.
Code: Select all
<?php
$foo = true;
if ($foo) {
echo 'content';
} else {
echo 'get lost';
}
// the above is exactly the same as this
if ($foo) {?>
output some stuff <html>
<?php }
if (!$foo) { ?>
<strong>get lost</strong>
<?php }
// either $foo is true or its not true,
// so only 1 of the 2 conditional statements will be executed
// it doesnt matter if they are in diff files