[英]Output line breaks from database
In my bio column in my database table I have this: 在我的数据库表的bio列中,我有以下内容:
This is a test. 这是一个测验。
Break 1. 休息1。
Break 2. 休息2。
I'm trying to output the text from the table column on my page like this: 我正在尝试像这样从页面上的表列中输出文本:
<?php echo escape (nl2br($data->bio)); ?>
But my output is returning like this on my webpage: 但是我的输出在我的网页上返回如下:
This is a test.<br /> Break 1.<br /> <br /> Break 2.
How can I make the line breaks output correctly? 如何使换行符正确输出?
This is my escape function: 这是我的转义功能:
<?php
function escape($string) {
return htmlentities($string, ENT_QUOTES, 'UTF-8');
}
try <?php echo nl2br (escape($data->bio)); ?>
尝试
<?php echo nl2br (escape($data->bio)); ?>
<?php echo nl2br (escape($data->bio)); ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.