php试图将n12br(新行)集成到我的php源代码中


php trying to integrate n12br (new line) to my php source

我在创建新行时遇到问题,所以只要有输入,它就会自动创建新行。

如果我想了解php,我需要学习如何更好地集成函数。。。

这是我的PHP:

<?php
$txt = "alertmon_user.txt"; 
if (isset($_POST['field1'])) { 
    $fh = fopen($txt, 'a'); 
    $txt = $_POST['field1']; 
    fwrite($fh,$txt); 
    fclose($fh); 
}
?>

谢谢

您可以使用PHP常量PHP_EOL

例如:

<?php
$txt = "alertmon_user.txt"; 
if (isset($_POST['field1'])) { 
    $fh = fopen($txt, 'a'); 
    $txt = $_POST['field1']; 
    fwrite($fh,$txt . PHP_EOL); 
    fclose($fh); 
}
?>