search
top

Variables – Good Form

This is a small example of the ‘good’ form of variable naming.  What’s good about it is the fact when you read the code:   echo “This $brand $model is a $year <br>”;  it is fairly easy to guess which variable is which.  Contrast this with the ‘bad form’ variables, which is much harder to read.

<html>
<body>
<h1>Variables</h1>
<?php
echo "<br>";
$brand="Ford";
$model="Explorer";
$year = 2003;

<span style="font-size: small;">echo "This $brand $model is a $year <br>";
?>
</body>
</html>

Should produce the following output

Variables

This Ford Explorer is a 2003

Leave a Reply

top