如何使用php在字符串中打印\n

ham*_*obi 0 php string parsing newline

我需要逐字打印\n的该内this.value.split

$rows .= "<textarea onkeyup='this.rows = (this.value.split(\"\n\").length||1);' ...
Run Code Online (Sandbox Code Playgroud)

我缩短了代码,因此更容易阅读.

PHP将其解析为新行.我怎样才能重写这个字符串,以便它实际打印\n

Nea*_*eal 5

两种方式:

echo "\\n"; //escape it

echo '\n'; //use single quotes
Run Code Online (Sandbox Code Playgroud)