To test the page code:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>php gets the line-wrapping problem in the form area data </title>
<body>
<?php
$content =empty ($_post[' content ')? Null:trim ($_post[' content '));
if (!empty ($content)) echo str_replace ("\ r", ' RL ', NL2BR ($content));
echo "\ r". ' <br/>----------Split Line----------------------'. ' \ r ";
if (!empty ($content)) echo str_replace ("\ n", ' NL ', NL2BR ($content));
echo "\ n". ' <br/>----------Split Line----------------------'. ' \ n ";
if (!empty ($content)) echo str_replace ("\ r", ' RL ', str_replace ("\ n", ' NL ', NL2BR ($content)));
echo "\ r". ' <br/>----------Split Line----------------------<br/> '. ' \ n ";
The echo ' Hello '. \ n '. ' Boys! ';
The echo ' Hello '. \ r '. ' Boys! ';
?>
<form action= "textareanl.php" method= "post" enctype= "Multipart/form-data" >
<textarea name= "Content" cols= "rows=" 6 "></textarea>
<br/>
<input type= "Submit" value= "submitted"/>
</form>
</body>
After opening in the browser, enter in the form:
When submitted, the results are displayed in the browser as follows:
In Notepad cocoa see the following results:
From the above results are visible:
The 1.PHP function nl2br () inserts an HTML newline character before each new line (\ r \ n) in the string:<br/>;
2.Windows line wrapping is (\ r \ n);
3. In Notepad, \ r or \ n has the function of wrapping;