34,333
edits
Changes
→Accessing PHP Variable Values
<pre>
<?php
echo "The number of shapes is $nnumberofShapes.";
?>
</pre>
?>
</pre>
The examples we have used for accessing varaible values are straightforward because we have always had a space character after the variable name. The question arises as to waht should be done if we need to put other characters immediately after the variable name. For example:
<pre>
<?php
echo "The Circle is the $numberOfShapesth shape";
?>
</pre>
What we are looking for in this scenario is output as follows:
<tt>The Circle is the $numberOfShapesth shape</tt>
Unfortunately PHp will see the ''th'' on the end of the $numberOfShapes variable name as being part of the name. It will then try to output the value of a variable called $numberOfShapesth, which does not exist.