2016-12-17 63 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); 
?> 
相關問題