phphttpwebrequestrequest

Can a value from $_POST *not* be a string?


In PHP, can a value from the global $_POST array be something else than an array or a string?

The goal is to not have to check if everything is something else than an array or string in a script. If I know what type a variable has, I don't have to do some weird validation. If I expect a string, I don't have to cast everything to a string to make sure it is one.


Solution

  • $_POST["key"] = true;
    
    var_dump($_POST["key"]); // bool(true)
    

    The values set by the environment are strings or arrays though.