首页 > 开发 > PHP > 正文

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

2024-05-04 21:56:28
字体:大 中 小
来源:转载
供稿:网友

这里简单的介绍了关于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. { 
  12.  $txt = $_POST['txt']; 
  13.  echo $txt.'<br />'; 
  14.  echo str_replace(chr(32),'&nbsp;',$txt); 
  15. } 
  16. ?> 

上一篇:php 缓存设计

下一篇:php网页显示乱码

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表