Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to echo lots of HTML between an IF statement

Tags:

php

At the moment my PHP code is like this:

<?php
some code
?>

lots of HTML

<?php
some more code
?>

I now want to include large chunks of HTML depending upon the values of certain PHP variables so like this:

<?php
if ($requiresSignature===true) {
 echo "some HTML";
 echo "some more HTML";
}
?>

Using echo is fine for a few lines of HTML but is there an easier way when I've got maybe 500 lines of HTML so I don't have to type echo in front of each line?

like image 523
Andy Groom Avatar asked Nov 30 '25 04:11

Andy Groom


1 Answers

You can do it this way

<?php
if ($requiresSignature===true) {
?>
 <b>some HTML</b>
 <b>some more HTML</b>
<?php
}
?>
like image 70
Rafael Shkembi Avatar answered Dec 02 '25 19:12

Rafael Shkembi