请问老师html标签中name和value的区别?
比如<input type="text" name="" value=""/>然后后台应该获取name还是value?
在单选中 name相同的话可以实现单选,那此时是靠value传到后台吗?
谢谢老师
1
收起
正在回答
1回答
您好,是根据name获取到的value值。例如:name值为username的input表单输入的value值是什么,在PHP代码中便可以输出相同的value值。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <!doctype html> <html lang= "en" > <head> <meta charset= "UTF-8" > <meta name= "viewport" content= "width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" > <meta http-equiv= "X-UA-Compatible" content= "ie=edge" > <title>Document</title> </head> <body> <form action= "" method= "post" > 用户名<input type= "text" name= "username" value= "" > <input type= "submit" value= "提交" > </form> </body> </html> <?php if ( $_POST ){ print_r( $_POST [ 'username' ]); } |
祝学习愉快!
PHP小白零基础入门
- 参与学习 人
- 提交作业 626 份
- 解答问题 4928 个
想要学好Web后端开发的中流砥柱语言,本阶段为你轻松铺就扎实的基础,从前端网页布局的搭建到后台PHP开发,助你从零基础到掌握主流开发语言。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧