In this lesson we'll be discussing HP variables you can think of a variable as a container for storing
information.
Variables can store both numerical and text data in this document.
We have some p p embedded in the body of our HMO in HP P A VARIABLE DECLARATION must start with the
dollar sign
followed by the variable name.
In this case we've named the first variable.
Var 1 the VAR 1 variable contains the value.
Hello world.
We also have two other variables declared X and Y X holds a value of 15 and Y holds a value of twenty
point five.
There are some basic rules when naming variables a variable must start with the dollar sign followed
by the name of the variable a variable name must start with the letter or the underscore character a
variable name cannot start with the number a variable name can only contain alphanumeric characters
and underscores variable names are case sensitive
when working with variables the p p echo statement is often used to output the data here.
We have output at the Values contained within each one of the variables we declared and this is done
using the echo statement.
We can see that we were outputting the value of 4 1 followed by an HMO break and then the value of x
break and then the value of y lastly will be outputting a horizontal line
and you can see the output here in our web browser.
Hello world the value of x is 15 and the value of y which is twenty point five
we can also output a combination of variables in text so here we declared a variable named sport containing
the value.
Football next we have an echo statement which outputs the words I like and then the value of the variable
sport which in this case is football and we can see the result over here.
This is the final output and we also have a horizontal line which you can see
we can also use another output method to achieve the same result
so here we have the same variable name.
Sport and the same value football.
The only difference is in the format of the echo statement.
In this next example we output the value of one variable added to another.
In this case x plus y.
That's what we have in our echo statement X has been assigned the value of 5 and Y has been assigned
the value of 6.
Notice that we don't have to put quotations around numerical values and when we add the values together
in our web browser we see that eleven is displayed.