首页 >后端开发 >php教程 >换行有关问题

换行有关问题

WBOY
WBOY原创
2016-06-13 10:26:11773浏览

换行问题
$fp = fopen("log.txt","a ");
fwrite($fp,date("Y-m-d H:i:s"));
fwrite($fp," ");
fwrite($fp,$_SERVER[REMOTE_ADDR]);
fwrite($fp," ");
fwrite($fp,$_SERVER[HTTP_X_REWRITE_URL]);
fwrite($fp," ");
fwrite($fp,$_SERVER[HTTP_USER_AGENT]);
fwrite($fp," ");
fwrite($fp,$_SERVER["HTTP_REFERER"]);
fwrite($fp," ");
fclose($fp); 
?>

这个是记录访问者ip的。怎么让写在txt里面换行啊,这是在一行显示的

------解决方案--------------------
在每个要换行的地方加入换行符就可以了。
fwrite($fp,"\t\r\n");
------解决方案--------------------

PHP code
$fp = fopen("log.txt","a ");fwrite($fp,date("Y-m-d H:i:s").PHP_EOL); //用PHP_EOL换行吧,跨平台的<br><font color="#e78608">------解决方案--------------------</font><br>PHP.EOL 和 \n都行的<br><font color="#e78608">------解决方案--------------------</font><br>fwrite($fp," ");<br>改为<br>fwrite($fp,PHP_EOL);<div class="clear">
                 
              
              
        
            </div>
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn