Nothing else, see an article on the PHP form conversion textarea line breaks, after reading, based on past experience, I feel some of the information in this article is not accurate ... So I personally php Get a list of newline characters in the data to study
Test page code:
<! DOCTYPE html PUBLIC "- // W3C // DTD XHTML 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "Content-Type" content = "text / html; charset = utf-8" />
<title> PHP Get Wrap Issues in Form Area </ title>
</ head>
<body>
<? php
$ content = empty ($ _ POST ['content'])? null: trim ($ _ POST ['content']);
if (! empty ($ content)) echo str_replace ("r", 'rl', nl2br ($ content));
echo "r". '---------- Partition line ----------------------'. "r";
if (! empty ($ content)) echo str_replace ("n", 'nl', nl2br ($ content));
echo "n". '---------- Partition line ----------------------'. "n";
if (! empty ($ content)) echo str_replace ("r", 'rl', str_replace ("n", 'nl', nl2br ($ content)));
echo "r". '---------- Split line ----------------------'. "n";
echo 'hello'. "n". 'boys!';
echo 'hello'. "r". 'boys!';
?>
<form action = "textareanl.php" method = "post" enctype = "multipart / form-data">
<textarea name = "content" cols = "20" rows = "6"> </ textarea>
<br />
<input type = "submit" value = "Submit" />
</ form>
</ body>
</ html>
Open in the browser, enter in the form:
From the above results we can see:
1. The PHP function nl2br () inserts HTML line breaks before each new line (rn) in the string:
2. Wows under the line is (rn);
In Notepad, r or n have the function of line breaks;