What does (int) $_GET['page'] mean in PHP?

后端 未结 9 1318
鱼传尺愫
鱼传尺愫 2021-02-18 23:02

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

9条回答
  •  梦毁少年i
    2021-02-18 23:35

    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

提交回复
热议问题