I have a conditional include but running into an issue.
For example, this works
<?php if($t==3)
echo 'Foo';
else
echo 'Foo something else';
?>
and this: doesn’t work
<?php if($t==3)
echo 'Foo';
include ('/home/path/public_html/includes/foo_one.php');
echo 'Example: one';
else
echo 'Foo something else';
include ('/home/path/public_html/includes/foo_two.php');
echo 'Example: two';
?>
Could you shed some light as to what I am doing wrong?
Or should I include the echoes within the include and just do echo include …blah else echo another include …
You need to use
{}when your blocks inside theif/elseare more than one line.You should use
{}anyway, it makes it easier to read, and prevents mistakes like this.