Reputation: 8130
I need to literally print \n
inside of the the this.value.split
$rows .= "<textarea onkeyup='this.rows = (this.value.split(\"\n\").length||1);' ...
I cut the code short so its easier to read.
PHP parses it as a new line. How can I rewrite this string so that it will actually print \n
??
Upvotes: 0
Views: 775
Reputation:
You need to backslash your backslash:
\\n
Alternatively, you could use single quotes to delimit your string, but this would mean you would have to escape all the literal single quotes.
Here is a demonstration: http://phpfiddle.org/main/code/s7g-ra9
Upvotes: 2
Reputation: 146310
Two ways:
echo "\\n"; //escape it
echo '\n'; //use single quotes
Upvotes: 5