2011-12-06 56 views
5

我想知道如何在php中創建我的網站日誌文件?這有助於我維護關於每個用戶訪問的頁面的數據,他們在我的網站上完成的所有操作均由&執行。所以任何哥們都可以幫助我?如何在php中創建我的網站的日誌文件?

感謝名單,

+0

你需要在你的日誌中註冊什麼? –

+0

你想存儲什麼信息?每個用戶訪問的頁面,一般操作......請更清楚! – 2011-12-06 13:07:10

回答

25
$file = 'people.log'; 
// The new person to add to the file 
$person = "John Smith\n"; 
// Write the contents to the file, 
// using the FILE_APPEND flag to append the content to the end of the file 
// and the LOCK_EX flag to prevent anyone else writing to the file at the same time 
file_put_contents($file, $person, FILE_APPEND | LOCK_EX); 

請參閱手冊頁file_put_contents()

+1

感謝您改善此答案。我已經刪除了我的downvote。 – Treffynnon