Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 向数据库添加新行,但不带/n_Php_Database_Html Entities - Fatal编程技术网

Php 向数据库添加新行,但不带/n

Php 向数据库添加新行,但不带/n,php,database,html-entities,Php,Database,Html Entities,简单例子 $text = 'First line second line'; 我希望文本有一个新行,但在数据库中,no要存储/n 我试着用 htmlspecialchars(),htmlspecialchars()我也尝试了这个 $text = str_replace("\n", "<br/&#62",$text); $text=str_replace(“\n”,“”,$text)??为什么不希望它是一个换行符?使用$

简单例子

$text = 'First line
second line';
我希望文本有一个新行,但在数据库中,no要存储
/n

我试着用

htmlspecialchars()
htmlspecialchars()
我也尝试了这个

$text = str_replace("\n", "<br/&#62",$text);

$text=str_replace(“\n”,“
”,$text)??为什么不希望它是一个
换行符
?使用
$text=nl2br($text)。如果您使用它来显示为html,建议按原样存储它,并在display中将其显示为

。我不想在数据库中使用新行,因为我使用user serialize()和新行使某些内容无法在数据库中工作,现在有
。但这也表现在文本中,它没有形成一条新的线条。