Now that we know what variables are in this video will learn what you can store in them.
Variables in P HP can store data of different types.
So far in our code.
We've created a variable that contains a string.
A string is simply some text are more specifically a sequence of characters between quotes.
The contents of the variable are its value.
What's between the quotes but the quotes aren't included in the value.
So these are all the valid string variables you can use single are double quotes to contain the value
as long as you use the same at both ends of the string.
There is a slight difference between single and double quotes.
When we come to process string values but we'll cover that in more detail later.
Variables can also contain numbers.
These numbers can be integers which are whole numbers that dont have a decimal part.
Integers can be positive or negative numbers like this.
Numbers can also have a decimal part.
These are known as float's a dot.
Period is used to separate the decimal part.
And of course these can be negative.
Also it's important to note that if you use a language other than English where decimals are separated
using a different character for example Spanish you still need to use the dupped are period when writing
a float value in p p.
One thing to be aware of is the difference between two variables like these.
The first one contains a number while the second one is a string.
It's a string that contains numeric characters but it's still a string.
They are not the same value.
You need to be aware of this when using variables but we're going to this in more detail later on.
Let's look at an example of some different variables.
We already have a string variable that we created earlier.
Let's add an integer and a float.
Instead of using airco to print this out.
Let's use p-h.
PS.
Dump function.
This is useful for seeing what value a variable contains.
Will go into functions in more detail later but to use this function you write that dump followed by
a variable in brackets.
This will print out the details of the variable in the browser.
Let's print out the details of the other two variables like that will save the file.
Now if we go to our page in the browser we can see that the VAR dump function has printed out the details
of our variables.
We have a 12 character string that contains the text.
Hello again.
An integer are in it with the value 3 and a float with the value.
One point ninety nine although you wouldn't use it in your final code.
The dump function is very useful if you want to see what a variable contains.
I use it's a whole the time when I am trying to work out what some code is doing.
You might have noticed that were not declaring these variables to be a specific type.
Unlike in some languages.
P H P is what's known as a loosely types language in some languages like Java for example which is strongly
typed.
When you declare a variable you have to declare its type in p p.
You could create a variable and stop any type of value in it like this.
This means it's very flexible but it can be easy to introduce errors if you are not careful.
Don't worry though we are going to be careful.