PixelPaul Posted April 2, 2019 Share Posted April 2, 2019 Why does the API only accept 0 or 1 values for Booleans? It is VERY limiting and anoying. It should also accept 'true' or 'false' as values. 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted April 2, 2019 Share Posted April 2, 2019 Do you have example code? From my experience the localAPI at least accepts them without tossing an error and using the value. 0 Quote Link to comment Share on other sites More sharing options...
PixelPaul Posted April 2, 2019 Author Share Posted April 2, 2019 yes, the internal API is fine. but the external API is not. i can not send form values such as... entry1=true&entry2=false&entry3=false it needs to be: entry1=1&entry2=0&entry3=0 well the true actually works because 1 and "true' both = truth. but 'false' also = truth. So this tells me they are doing a if value == 1 which is bad programming. it should be if value === boolean truth / false 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted April 3, 2019 Share Posted April 3, 2019 $_POST only provides strings, so they would need: A boolean check for if $v === 1 / 0 A string check for if $v === "true" / "false" Also, it is standard PHP to use 1 or 0 in place of booleans but using a string that just says "true" or "false" isn't as far as I know / have seen. How is giving 1 or 0 limiting? 0 Quote Link to comment Share on other sites More sharing options...
PixelPaul Posted April 3, 2019 Author Share Posted April 3, 2019 exactly: it's okay in PHP. But any other environment makes it very limiting, such as interacting with the API from nodejs/browser/javascript. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.