The HTML execution process can be done by separating by PHP opening <?php and closing ?> tags . If you want to run HTML code without echo then you should separate HTML code.
Example 1-
<?php
//PHP code here
?>
<h2> This is HTML heading <?php echo $var; ?></h2>
<?php
//PHP code here
?>
You can use HTML code if you separate HTML and PHP code inside PHP tags(<?php ?> ).
Example 2 -
<?php
$i=1995;
while($i<=2001)
{
?>
<h2>Year:-<?php echo $i;?></h2>
<?php
$i++;
}
Output -
Year:-1995
Year:-1996
Year:-1997
Year:-1998
Year:-1999
Year:-2000
Year:-2001
In this example, we are displaying years from 1995 to 2001 and separating HTML code without echo inside PHP code.
HTML code can be executed by including a file.
Create a file like - myfile.php
myfile.php
<h2>This is HTML code. </h2>
<p>This is paragraph. </p>
Now, include() file in PHP .
<?php
include('myfile.php');
$var='Hello';
?>
In these ways , you can execute HTML code inside PHP without echo.