php实现记事本案例

吾爱主题 阅读:156 2021-10-27 13:48:00 评论:0

本文实例为大家分享了php实现记事本的具体代码,供大家参考,具体内容如下

记事本案例

要求:1)页面上有一个文本域(textarea元素),和一个发表按钮
           2)用户在文本域中输入内容后,点击发表按钮,会以当天的日期和时间创建一个记事本,并将用户输入的内容保存到记事本中

效果:

代码:

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 <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= "发表" ></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);     ?>

拓展知识点:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/december_shi/article/details/109148339

可以去百度分享获取分享代码输入这里。
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

【腾讯云】云服务器产品特惠热卖中
搜索
标签列表
    关注我们

    了解等多精彩内容