php實現(xiàn)記事本案例
更新時間:2020年10月20日 16:51:43 作者:December_shi
這篇文章主要為大家詳細介紹了php實現(xiàn)記事本案例,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了php實現(xiàn)記事本的具體代碼,供大家參考,具體內(nèi)容如下
記事本案例
要求:1)頁面上有一個文本域(textarea元素),和一個發(fā)表按鈕
2)用戶在文本域中輸入內(nèi)容后,點擊發(fā)表按鈕,會以當天的日期和時間創(chuàng)建一個記事本,并將用戶輸入的內(nèi)容保存到記事本中
效果:
代碼:
<style> textarea{ resize: none; border: 2px solid #000; outline: none; } input{ margin-top: 15px; width: 80px; height: 30px; border: none; outline: none; color: #fff; background-color: orange; } </style> <form action="4.php" method="post"> <textarea name="text" id="" cols="30" rows="10"></textarea> <div><input type="submit" name="btn" value="發(fā)表"></div> </form> <?php // 方法一 $file=$_POST['text']; $filename = date('Ymd',time()).'.txt'; $fh=fopen($filename,'a'); fwrite($fh,$file); fclose($fh); // 方法二 // file_put_contents('1.txt',$file); ?>
拓展知識點:
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
php在windows環(huán)境下獲得cpu內(nèi)存實時使用率(推薦)
這篇文章主要介紹了php在windows環(huán)境下獲得 cpu 內(nèi)存實時使用率的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2018-02-02基于Linux調(diào)試工具strace與gdb的常用命令總結(jié)
本篇文章是對Linux調(diào)試工具strace與gdb的常用命令進行了總結(jié)與分析,需要的朋友參考下2013-06-06