加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php解决input输入多个空格只显示一个的问题

发布时间:2020-12-13 20:39:05 所属栏目:PHP教程 来源:网络整理
导读:这里简单的介绍了关于php解决input输入多个空格只显示一个的问题,我们利用了chr(32)来替换成html空格符,实例代码如下: body formid= form1 name= form1 method= post action= label for = textfield /label inputtype= text name= txt id= txt / inputtype

这里简单的介绍了关于php解决input输入多个空格只显示一个的问题,我们利用了chr(32)来替换成html空格符,实例代码如下:

  1. <body> 
  2. <form id="form1" name="form1" method="post" action=""
  3.   <label for="textfield"></label> 
  4.   <input type="text" name="txt" id="txt" /> 
  5.   <input type="submit" name="button" id="button" value="提交" /> 
  6. </form> 
  7. </body> 
  8. </html> 
  9. <? 
  10. if$_POST ) 
  11.  $txt = $_POST['txt']; 
  12.  echo $txt.'<br />'
  13.  echo str_replace(chr(32),'&nbsp;',$txt); 
  14. ?> 

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读