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

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".

您是否知道何时通过PHP提交表单,表单复选框值被视为字符串“true” “或布尔值是真的吗? 假设我的checkbox值属性设置为“true”。 p> div>

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).