X
X
XenK2017-10-17 08:58:51
PHP
XenK, 2017-10-17 08:58:51

Yii2 comes empty instead of false?

I send JSON (POST):

{
  "id": 1,
  "param": false
}

Output:
print_r(Yii::$app->request->post());
I get an empty param :
Array
(
    [id] => 1
    [param] => 
)

And it needs to be like this:
Array
(
    [id] => 1
    [param] => false
)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lander, 2017-10-17
@XenK

print_r does not display false and null. Use var_dump.
upd: or rather, at the time of display, print_r does __toString for each element. And for false __toString returns an empty string. Therefore, it is not displayed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question