doutangkao2789 2011-11-05 23:13
浏览 52
已采纳

PHP提交的复选框值是字符串还是布尔值?

Do you guys know when you submit a form via PHP, is the form checkbox value being treated as the string "true" or boolean true? Assuming my checkbox value attribute was set to "true".

  • 写回答

1条回答 默认 最新

  • douhan1992 2011-11-05 23:14
    关注

    When you submit a checkbox, the value will be whatever you set the value attribute as, and will be a string when PHP parses the form data and populates $_REQUEST and friends.

    If you don't specify a value in the form, then browsers default to "on", not "true" (this is being made standard behaviour in HTML 5).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?