Home > php教程 > php手册 > php解决input输入多个空格只显示一个的问题

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

WBOY
Release: 2016-05-25 16:52:57
Original
1115 people have browsed it

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

<body> 
<form id="form1" name="form1" method="post" action=""> 
  <label for="textfield"></label> 
  <input type="text" name="txt" id="txt" /> 
  <input type="submit" name="button" id="button" value="提交" /> 
</form> 
</body> 
</html> 
<?php
if( $_POST ) 
{ 
    $txt = $_POST[&#39;txt&#39;]; 
    echo $txt.&#39;<br />&#39;; 
    echo str_replace(chr(32),&#39; &#39;,$txt); 
} 
?>
Copy after login


永久地址:

转载随意~请带上教程地址吧^^

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template