记事本,同时只能记录一个文件,存为了txt文本文档
注意本例用了一些css和js文件,请在演示页面另存为后查看
演示
?
PHP Code
- <?php??
- ??
- $note_name?=?'note.txt';??
- $uniqueNotePerIP?=?true;??
- ??
- if($uniqueNotePerIP){??
- ??????
- ????//?Use?the?user's?IP?as?the?name?of?the?note.??
- ????//?This?is?useful?when?you?have?many?people??
- ????//?using?the?app?simultaneously.??
- ??????
- ????if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){?
- ????????$note_name?=?'notes/'.md5($_SERVER['HTTP_X_FORWARDED_FOR']).'.txt';?
- ????}?
- ????else{?
- ????????$note_name?=?'notes/'.md5($_SERVER['REMOTE_ADDR']).'.txt';?
- ????}?
- }?
- ?
- ?
- if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])){?
- ????//?This?is?an?AJAX?request?
- ?????
- ????if(isset($_POST['note'])){?
- ????????//?Write?the?file?to?disk?
- ????????file_put_contents($note_name,?$_POST['note']);?
- ????????echo?'{"saved":1}';?
- ????}?
- ?????
- ????exit;?
- }?
- ?
- $note_content?=?'??
- ??
- ????????????????Write?your?note?here.??
- ??
- ?????????????It?will?be?saved?with?AJAX.';??
- ??
- if(?file_exists($note_name)?){??
- ????$note_content?=?htmlspecialchars(?file_get_contents($note_name)?);??
- }??
- ??
- ?>??
?
XML/HTML Code
- <div?id="pad">??
- ????????????<h2>Note</h2>??
- ????????????<textarea?id="note"><?php?echo?$note_content??></textarea>??
- ????????</div>??
?
原文地址:http://www.freejs.net/article_jquerywenzi_68.html