当我使用函数nl2br($ text)时,它不显示我想要的中断,而是显示中断的位置。我为用户显示确认页面,显示他们在表单中输入的详细信息。为什么我的nl2br()函数显示 r而不是中断(<br />)? PHP
(the confirmation code in php)
// Confirm success with the user
echo '<p>You have successfully posted a ad.';
echo 'Here is your posting: <br /><br />';
echo 'Title: ' .$title. '<br />' ;
echo 'Price $: ' .$price.'<br />' ;
echo 'Location: ' .$city. ' ' .$state. '<br />' ;
echo '<b>Detail: </b>' .nl2br($detail). '<br />';
(The form users fill out)
<div class="fieldwrapper">
<label for="detail" class="styled">Detail:</label>
<div class="thefield">
<textarea id="detail" name="detail"><?php if (!empty($detail)) echo $detail; ?></textarea>
(The output)
This is a test\r\n\r\ntesting is good\r\n\r\nWhy doesn\'t it work?
谨慎显示代码? – 2010-03-31 18:20:19
当我做了一个echo'测试运行详情:'.nl2br($ detail)。 '
'本身,它似乎工作,并会显示空格,而不是\ r \ n。只有在这里它似乎没有工作 – ggfan 2010-03-31 18:27:34