How to read if a checkbox is checked in PHP?

后端 未结 18 981
刺人心
刺人心 2020-11-22 07:54

How to read if a checkbox is checked in PHP?

18条回答
  •  死守一世寂寞
    2020-11-22 08:40

    You can do it with the short if:

    $check_value = isset($_POST['my_checkbox_name']) ? 1 : 0;
    

    or with the new PHP7 Null coalescing operator

    $check_value = $_POST['my_checkbox_name'] ?? 0;
    

提交回复
热议问题