I tried looking up (int)
but could only find documentation for the function int()
in the PHP manual.
Could someone explain to me what the above
What you are looking at there is known as type casting - for more information, see the manual page on type juggling.
The above piece of code casts (or converts) $_GET['page']
to an integer.
this kind of syntax (int)
is called type casting. Basically it takes the variable following it and tries to force it into being an int
it casts the variable following it to integer. more info from documentation: http://php.net/manual/en/language.types.type-juggling.php
Type casting in PHP works much as it does in C: the name of the desired type is written in parentheses before the variable which is to be cast.
The casts allowed are:
- (int), (integer) - cast to integer
- (bool), (boolean) - cast to boolean
- (float), (double), (real) - cast to float
- (string) - cast to string
- (array) - cast to array (object) - cast to object
- (unset) - cast to NULL