我正在为读者创建一个帖子区域,我的问题是,当用户插入新帖子时,它将以这种形式保存到数据库中:
Some say the world will end in fire,<br /> Some say in ice.<br /> From what I’ve tasted of desire<br /> I hold with those who favor fire.<br /> But if it had to perish twice,<br /> I think I know enough of hate<br /> To say that for destruction ice<br /> Is also great<br /> And would suffice.
我希望这样保存它:
Some say the world will end in fire,<br />
Some say in ice.<br />
From what I’ve tasted of desire<br />
I hold with those who favor fire.<br />
But if it had to perish twice,<br />
I think I know enough of hate<br />
To say that for destruction ice<br />
Is also great<br />
And would suffice.
我希望它在每次换行后都保留标签(用于编辑问题)“输入”
在插入数据库之前,这是我当前的发布文本参数
$body = strip_tags($body);
$body = mysqli_real_escape_string($this->con,$body);
$body = str_replace('\r\n',"\n",$body);
$body = nl2br($body);