换行问题
<?php
$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");
[解决办法]
$fp = fopen("log.txt","a ");fwrite($fp,date("Y-m-d H:i:s").PHP_EOL); //用PHP_EOL换行吧,跨平台的
[解决办法]
PHP.EOL 和 \n都行的
[解决办法]
fwrite($fp," ");
改为
fwrite($fp,PHP_EOL);