Home > Backend Development > PHP Tutorial > thinkPHP5怎么获取多选按钮的值

thinkPHP5怎么获取多选按钮的值

PHPz
Release: 2020-09-04 13:59:59
Original
1784 people have browsed it

thinkPHP5获取多选按钮的值的方法:首先修改HTML页面部分代码为“”;然后修改控制器代码,这样就可以获取多选按钮的值了。

thinkPHP5怎么获取多选按钮的值

thinkPHP5怎么获取多选按钮的值?

HTML页面部分: 

<input type="checkbox" name="teachers[]" value="王老师" /> 
<input type="checkbox" name="teachers[]" value="张老师"/> 
<input type="checkbox" name="teachers[]" value="李老师"/> 
<input type="checkbox" name="teachers[]" value="宋老师"/> 
<input type="checkbox" name="teachers[]" value="刘老师"/>
Copy after login

控制器部分:

$teachers = input(&#39;post.teachers/a&#39;); 
return var_dump($teachers);
Copy after login

在获取CheckBox的多个值时务必要使用/a修饰符,这里简要介绍一下几个修饰符的含义: 

* s强制转换为字符串类型 

* d强制转换为整型类型 

* b强制转换为布尔类型 

* a强制转换为数组类型 

* f强制转换为浮点类型

推荐:《TP5

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template