As you saw in JavaScript a variable is a container for data.  In PHP you do not need to declare a variable you just use it.  Open phpquotes.php and save it as phpvariables.php.  Add this line above the echo line:

echo "<p>Hello ";
echo $name;
echo ", how are you?</p>";

Look through that and you should be able to see what it will do once you know that $ marks a variable in PHP:HTML as generated by PHP and shown in a browser

The code is ugly and that is one of the problems with PHP.  You will learn a slightly better way soon but it still often looks cluttered.

Upload and try.  View the source of the page in your browser and you should see a paragraph element (although it has messed your nice indenting up).  The PHP has combined the data in the variable with text to make a new paragraph.  None of the PHP shows up just the HTML.  Compare the code above with the end result until you see how PHP works.


Just like in JavaScript PHP does not care if you put numbers or text into variables.  Add this code just below the other five lines:

echo "<p>I understand you are ";
echo $months;
echo " months old</p>";

The asterisk is used for multiplication in most programming languages but apart from that the new code should be clear enough.  Upload and try.

PHP variable using a number

Variable names

As with JavaScript do not have spaces or special characters in variable names.  You can use _ and - and some others but try not to.  Instead use camel case to make the variable names easier to read.  For example: