34,333
edits
Changes
→Accessing PHP Variable Values
== Accessing PHP Variable Values ==
Now that we have learned how to create a variable and assign an initial value to it we now need to look at how to access the value currently assigned to a variable.In practice, accessing a variable is as simple as referencing the name it was given when it was created. For example, if we want to display the value which we assigned to our ''numberOfShapes'' variable we can simply reference it in our ''echo'' command: <pre><?phpecho "The number of shapes is $n.";?></pre> This will cause the following output to appear in the browser: <tt>The number of shapes is 6.</tt> Similarly we can display the value of the ''myShape'' variable: <pre><?phpecho "$myShape is the value of the current shape.";?></pre>