PHP获取表单textarea数据中的换行问题
前端之家收集整理的这篇文章主要介绍了
PHP获取表单textarea数据中的换行问题,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
测试页面代码:
<div class="codetitle"><a style="CURSOR: pointer" data="52538" class="copybut" id="copybut52538" onclick="doCopy('code52538')"> 代码如下:
<div class="codebody" id="code52538">
<!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">
PHP获取表单area数据中的换行问题 <?
PHP $content=empty($_POST['content'])?null:trim($_POST['content']);
if(!empty($content))echo str_replace("\r",'rl',nl2br($content));
echo "\r".'
----------分割线----------------------'."\r";
if(!empty($content))echo str_replace("\n",'nl',nl2br($content));
echo "\n".'
----------分割线----------------------'."\n";
if(!empty($content))echo str_replace("\r",str_replace("\n",nl2br($content)));
echo "\r".'
----------分割线----------------------
'."\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">