Next up, let's talk about the data types.
Remember that all that you can see here.
You can also download under this video.
Let me zoom in a bit and start with the scalar types.
The simple types.
So that's an integer for example.
So the whole numbers the floats for floating point numbers strings and booleans which basically hold
a true or false value.
Then we've got the compound types.
This would be an array and object.
So with arrays we've got indexed arrays where you just have items in the array.
And there are indexed with the next numbers starting always with zero.
And then there is an associative array where under a specific key you've got some value.
This is similar to map types in other languages.
You can also have nested arrays which is a multi-dimensional array, which means that you can have an
array inside an array.
So PHP also supports objects which are created based on classes.
We're going to cover objects in depth later on.
Next up you should know about special types in PHP like null, which just means an empty value.
And this null is same like in other programming languages like JavaScript for example.
Then there is the resource type, which is often something returned when you work with files.
Next up, let's read a little about the behavior of types in PHP.
So you should know that there is something called implicit types.
So if you define a variable, you don't explicitly have to define, or you can't even define the type
of this variable, it is implicitly assumed.
Now, I'm not saying there is no way to define explicit types in PHP, because there is a way and you
can add explicit types to function arguments.
Return types and class fields.
But we're going to only learn about those later on, so I just leave it for later.
So if you use variables then they are typed implicitly.
In this case A would just be an integer.
But you can cast types.
So you can cast this a variable which in this case has a value of.
Well that depends how you read that.
You can read this as 55, but this can also be read as character five, followed by character five.
And if you use the casting operator to integer.
Every type has its own casting operator.
This would be converted to an integer.
In this case this would result in 55.
Next up you should know about the type coercion, which is automatic casting to another type.
So if you would like to compare the string five with a number five.
So two values or two expressions that are of different type and you use the comparison operator for
that, then five as a string would be implicitly casted to integer just for this comparison to be run.
Next up there is strict and weak typing, so we can add a declaration that would enforce the types more
strictly.
That's for later.
And as I've said previously, you can also in certain cases define the explicit types like for example,
function arguments can be typed.