Mixed mode

Process of turning the PHP parser on / off as required.

 

Simply close the PHP code with a ?> then carry on in normal HTML as required, then when ready go back in to PHP mode with a new <?php starting tag.

 

Allows HTML code to be output based on conditional code within the PHP.

 

<?php
	$myVar = rand(1,2) ;

	if ($myVar == 1) {
?>
	<h1>Conditional HTML</h1>
	<p>This will only be displayed if the above PHP 'if'<br>
	test expression is TRUE!</p>
<?php
	} else {
?>
	<h1>More Conditional HTML</h1>
	<p>This will only be displayed if the above PHP 'if'<br>
	test expression is FALSE!</p>
<?php
	}
?>

Leave a Reply