html in php else if statement?

Nick J

New member
im trying to add several pages of html in one php page using else if statements. is there a way to do this without using echo on every single line, or is it best just to include the different pages
 
yes.
<?php if (condition) {?>
put html code here or whatever you like
<?php } elseif(condition) {?>
put other code here as well
<?php } else {?>
put even more code
<?php } ?>

you can jump in and out of php at any time you like OR you can use one echo per if:

<?php
if(condition) {
echo "html code here...";
} elseif(condition) {
echo "more html here...";
} else {
echo "even more here...";
}
?>

hope this helps.
 
Back
Top