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.

[php]
<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>
[/php]

Should produce the following output

[box] Variables

This Ford Explorer is a 2003

[/box]

Leave a Reply