我知道在这个论坛和其他论坛中有多个这样的例子,我已经尝试了所有的例子,但都无法正常工作。我得到了一个写入php文件的php脚本,它被加载到php脚本中。
我的目的是在人们按下"输入"后自动将 br-tag 放入 php-post 中
<?php
if ( isset( $_POST[ 'submit' ] ) ) {
$com = $_POST['txt'];
If ($com === "") {
echo "<font color=red><b>You must write something to post!</font></b>";
die;
}
$time = gmdate("M d Y H:i:s",time()+(2*60*60));
$com = $_POST['txt'];
$count = strlen($com);
$com = stripslashes($com);
$breaks = array("<br />","<br>","<br/>");
$com = str_ireplace($breaks, "'r'n", $com);
$fp = $file = fopen( "NAME_OF_POST.php", "a");
Multiple fwrites follows.....
Multiple fwrites follows.....
rewind($fp);
fclose($fp);
echo '<script type="text/javascript">window.location ="";</script>';
}
?>
它加载在:
<textarea name="txt" id="area" class="typo_vind" placeholder="......" tabindex="1"></textarea>
有人知道如何从输入中获取换行符以替换为 br 标签吗?
提前,比你:)!
好吧,php有一个函数:
$yourString = "text
with
enters";
$result = nl2br( $yourString );
print $result
// output:
// text<br>with<br>enters
查看文档
$breaks = array("'n");
$com = str_ireplace($breaks, "<br />", $com);
换个地方起到了作用:)谢谢大家:)
OMG !!!!!!
$breaks = array("'n");
$com = str_ireplace($breaks, "<br />", $com);
经过大量搜索,这工作得很好!!!!!!♥☻☻☻♥♥♥