here’s what I’m wanting to do:
<? include 'header.php' ?>
some html
<? include 'footer.php' ?>
in header.php…
<? //bunch of code
if (something){
//some stuff here, but no close brace
?>
in footer.php….
<? } //close the if brace ?>
Is this possible? I keep getting parse errors.
Thanks.
No, you can’t do that. Your brackets all need to be in the same file.
If you want to conditionally include HTML, put your logic in the file that
includes header.php and footer.phpAlso, don’t use ASP-style (
<? ?>) short-open tags. They’re being deprecated. You can still use<?= ?>to output variables and such.Here’s an interesting conversation on that topic.
And here’s the notes from the PHP manual.