微慑信息网

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);
?>

测试以上根本不会通过\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);
?>

 

本文标题:PHP文本换行控制
本文链接:
(转载请附上本文链接)
https://vulsee.com/archives/vulsee_2019/0527_7758.html
转载请附本站链接,未经允许不得转载,,谢谢:微慑信息网-VulSee.com » PHP文本换行控制
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

微慑信息网 专注工匠精神

访问我们联系我们