Convert boolean to integer value php

前端 未结 7 1641
广开言路
广开言路 2021-02-04 23:58

Is there any builtin function for PHP that will take a boolean value and return its integer equivalent? 0 for FALSE, 1 for TRUE? Of course you can easily create a function to do

7条回答
  •  臣服心动
    2021-02-05 00:16

    Use type casting (bool):

    var_dump((bool) 1);         // bool(true)
    var_dump((bool) 0);         // bool(false)
    

提交回复
热议问题