2016-12-17 62 views

回答

0

发送日志服务器,例如使用jQuery:

$.post("/log/save.php", 
    log: "Hello world", 
    function(){ 
     console.log("log saved") 
    } 
); 

然后/log/save.php连接到数据库,并保存到记录表保存日志文件:

<?php 
$file = 'logs.txt'; 
// Open the file to get existing content 
$current = file_get_contents($file); 
// Append a new log to the file 
$current .= $_POST["log"]."\n"; //hello world. 
// Write the contents back to the file 
file_put_contents($file, $current); 
?> 
相关问题