New line in PHP output in a text file

前端 未结 8 2076
甜味超标
甜味超标 2021-01-04 17:05

My php form which saves the output in a text file glues the result to one string like:

Name1Email1The Message1Name2Email2The Message2Name3Email3The Message3Name4Emai

8条回答
  •  臣服心动
    2021-01-04 17:47

    You can use "\n" to write a new line.

    $data = $_POST['name'] . "\n";
    $data .= $_POST['email'] . "\n";
    $data .= $_POST['message'] . "\n";
    

    Just as a sidenote, \n has to be in doublequotes. When surrounded by single quotes it won't work.

提交回复
热议问题