php无法解释导出函数的转义字符

php无法解释导出函数的转义字符,php,string,Php,String,我的php服务器无法将“\n”解释为(LF或CR)。我的php.ini有问题吗 下面是一个示例代码: <?php echo "hell o boys \n hell o girls \t hell o gays"; ?> 我期望在哪里 hell o boys hell o girls hell o gays 我需要帮助。真的为这样的小事烦恼。 我不想用正则表达式 在本例中,我想使用下面的函数,但由于escape char prolem,它无法工作。 在这里: 使用

我的php服务器无法将“\n”解释为(LF或CR)。我的php.ini有问题吗

下面是一个示例代码:

<?php echo "hell o boys \n hell o girls \t hell o gays"; ?>
我期望在哪里

hell o boys 
 hell o girls      hell o gays
我需要帮助。真的为这样的小事烦恼。 我不想用正则表达式

在本例中,我想使用下面的函数,但由于escape char prolem,它无法工作。 在这里:

使用

用于替换为换行符的函数\n。像这样

$str = "hell o boys \n hell o girls \t hell o gays";

echo nl2br($str);
使用

用于替换为换行符的函数\n。像这样

$str = "hell o boys \n hell o girls \t hell o gays";

echo nl2br($str);
如果你想用html显示代码。 试一试

echo“{$a}”;
如果你想用html显示代码。 试一试

echo“{$a}”;

您可以将

用于新行..浏览器不会将
\n
视为新行,就像空白一样;您需要使用html

标记。如果要写入文本文件,请使用
\n
(或内置的PHP\u EOL常量)。可以使用

换行。浏览器不会将
\n
视为新行,就像空白一样;您需要使用html

标记。如果要写入文本文件,请使用
\n
(或内置的PHP\u EOL常量)。
nl2br
$str = "hell o boys \n hell o girls \t hell o gays";

echo nl2br($str);
$a = "hell o boys \n hell o girls \t hell o gays";    
$a=str_replace('\n',PHP_EOL,$a);
echo $a;
echo "<pre>{$a}</pre>";