取得checkbox复选框中的值,代码如下:
<?php if (isset($_POST['submit'])) { echo "您喜欢的编程语言:<br />"; foreach($_POST['languages'] AS $language) echo "$language<br />"; } ?> <form action="index.php" method="post"> 选择你喜欢的编程语言--练习php操作checkbox复选框的方法): <input type="checkbox" name="languages[]" value="csharp" />C#<br /> <input type="checkbox" name="languages[]" value="jscript" />JavaScript<br /> <input type="checkbox" name="languages[]" value="perl" />Perl<br /> <input type="checkbox" name="languages[]" value="php" />PHP<br /> <input type="submit" name="submit" value="提 交" /> </form>