Code Blocks

The use of { } to separate multiple lines of related statements from the rest of script.

 

<?php
	echo "Here's an echo statement<br>" ;

	$someVar = "Hi there<br>" ;

	while ($myVar < 5)
	{	//this is the start of the code block
		echo "\$myVar is currently $myVar<br>" ;
		echo "Some other wizzy code could go here" ;
		echo "Hey, let's increment \$myVar<br>" ;
		$myVar++ ;
		echo "<br>" ;
	}	//this is the end of the code block

	echo $someVar ;

	if (0) {
		//nothing going on here
	}
?>

Leave a Reply