Skip to content
Advertisement

Tag: boolean

How can I access the json returned in PHP by my Web Api?

I am using the following code to send and retrieve data from my Web API this is what I get in response I am trying to access the JSON with the following code (Because it worked for me on a similar request): But as you can see the variable $data stopped being a JSON and became a bool(true). Does anyone

Cast a column as Boolean in PDO

I have a field (‘done’) in the Database which is boolean. The function which GET/ the rows doesn’t return a json with that field as boolean but it returns 1 or 0. How can I get THAT column (‘done’ column) as boolean? I mean, Is posible to cast a column with PDO::PARAM_BOOL ?? Here is my sample of UPDATE that

Test if string could be boolean PHP

I’m getting a string from a $_GET and I want to test if it could be a boolean, before I use it for a part of a mysql query. Is there a better way of doing it than: Answer There’s, by the way, a cleaner way of writing it: But yes. The one you wrote down is the only way.

PHP – Get bool to echo false when false

The following code doesn’t print out anything: But the following code prints 1: Is there a better way to print 0 or false when $bool_val is false than adding an if statement? Answer Or if you only want output when it’s false:

Advertisement