0

我将 div 的内容存储在 textaera 中,然后将内容发布到另一个页面。

第二页应该简单地打印出 html,就好像它是直接写在那个页面中一样。

内容显示,除了 html 中的任何地方都有“,它被打印为 \”(例如在图像源和 ids 上)

为什么会发生这种情况,我能做些什么来避免它?

的HTML:

<textarea name="message" rows="10" cols="34"><table><tr>
      <td style="color: #333333;table-layout:fixed;text-align:left;vertical-align:top;" id="imgCell3"><img src="https://www.pnrbuilder.com/_images/itinerary/airlines_AC.gif"><br>
        AC # 7469</td>
      <td class="itinCell">06:30 AM on Tue, October 22, 2013<br>
        Newark/Elizabeth, NJ (EWR): Newark Liberty Intl. Airport</td>
      <td class="itinCell">8:03 AM on Tue, October 22, 2013 <br>
        Mississauga,&nbsp;Ontario,&nbsp;Canada (YYZ): Toronto Pearson Intl. Airport</td>
      <br>
    </tr>
  </table></textarea><br /><br />
<input type="submit" value="POST"/>

php:

echo '<strong>This is the email content as it was posted to the page:</strong><br>'.$_POST['message'].'<br><br><br>';

生成的源代码由 php 回显:

<strong>This is the email content as it was posted to the page:</strong><br><table><tr>
      <td style=\"color: #333333;table-layout:fixed;text-align:left;vertical-align:top;\" id=\"imgCell3\"><img src=\"https://www.pnrbuilder.com/_images/itinerary/airlines_AC.gif\"><br>
        AC # 7469</td>
      <td class=\"itinCell\">06:30 AM on Tue, October 22, 2013<br>
        Newark/Elizabeth, NJ (EWR): Newark Liberty Intl. Airport</td>
      <td class=\"itinCell\">8:03 AM on Tue, October 22, 2013 <br>
        Mississauga, Ontario, Canada (YYZ): Toronto Pearson Intl. Airport</td>
      <br>
    </tr>
  </table>
4

1 回答 1

2

尝试在 php 中使用 stripslashes() 来取消转义引号。参考http://www.php.net/manual/en/function.stripslashes.php

于 2013-09-29T11:37:28.657 回答