I'm getting true or false from query string i don't have access to change this www.example.com?is_test=true
But in backend for database i'm excepting integer like 0,1
To achieve this i'm trying like this
(int) (boolean) 'true' //gives 1
(int) (boolean) 'false' //gives 1 but i need 0 here
Event i tried
$test = "false";
$bool = settype($test, 'boolean'); //it was giving true
(int) $bool also gives 1
i'm not sure there might be some other better php function to achieve this? Or any better way to this please suggest
Yah ternary operator is one best option But is there any other options for conversion