Changes

Jump to: navigation, search

An Introduction to PHP Variables

312 bytes added, 16:42, 25 May 2007
Accessing PHP Variable Values
<pre>
<?php
echo "The number of shapes is $numberofShapesnumberOfShapes.";
?>
</pre>
<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.This result in nothing being displayed for this variable: <tt>The Circle is the shape</tt> Fortunately we can get around this issue by placing braces around the variable name to distinguish the name from any other trailing characters: <pre><?phpecho "The Circle is the ${numberOfShapes}th shape";?></pre>

Navigation menu