加入收藏 | 设为首页 | 会员中心 | 我要投稿 厦门网 (https://www.xiamenwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 移动互联 > 正文

php实现记事本案例

发布时间:2020-10-24 13:15:57 所属栏目:移动互联 来源:网络整理
导读:这篇文章主要为大家详细介绍了php实现记事本案例,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

要求:1)页面上有一个文本域(textarea元素),和一个发表按钮

2)用户在文本域中输入内容后,点击发表按钮,会以当天的日期和时间创建一个记事本,并将用户输入的内容保存到记事本中

效果:

代码:

<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 cols="30" rows="10"></textarea>
 <div><input type="submit" 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);
?>

拓展知识点:

(编辑:厦门网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读