PHP在Post之后添加空格
我的代码是:PHP在Post之后添加空格,php,Php,我的代码是: <table width="100%" class="table-striped"> <tr> <td colspan="7"><h4>Cagayan de Oro</h4></td> </tr> <tr> <th>Time</th> <th>Temperature<
<table width="100%" class="table-striped">
<tr>
<td colspan="7"><h4>Cagayan de Oro</h4></td>
</tr>
<tr>
<th>Time</th>
<th>Temperature</th>
</tr>
<tr>
<td align="center"><?php echo $_SESSION['Timez'][0]; ?></td>
<td align="center"><input type="number" maxlength="2" placeholder="Temp" name="Temp1" style="width: 60px;" value="<?php if (isset($_POST['post'])) echo $_POST['Temp1'];?>"></td>
<p align="right">
<input type="submit" name ="post" value="Assimilate" class="btn-primary">
</p>
</form>
卡加延德奥罗酒店
时间
温度
从字符串中删除空格
因此,在这样打印时使用它作为您的代码
trim($\u POST['Temp1'])
而不是使用
$\u POST['Temp1']
您也可以使用
$string=preg_replace('/\s+/','$string)
要从字符串中删除所有多余的空格。请使用trim(_POST['Temp1'])
要从您的POST值中删除空格,请使用trim()
来修剪空格。谢谢。但是我不明白为什么它增加了34个空格。请关闭你的输入标签,这也可能会导致你这个问题。难道没有输入的结束标签吗?哦,我明白了。修剪功能工作。向输入中添加标记的结束符不会忽略空格。