编写文本文件php [英] Write text file php

查看:102
本文介绍了编写文本文件php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用php.

我想编写一个php页面以从另一个页面获取参数并写入文件文本.并且:

I want to write a php page to get parameters from another page and write to a file text. And:

  • 如果已经有文件文本,它将写入新行

  • If already have file text, it write to a new line

每天创建一个文件文本

示例:

register.php

register.php

<body>
    <form action='process.php' method='GET'>
        Name: <input type='text' name='name'/>
        <br/>
        Age: <input type='text' name='age'/>
        <br/>
        <input type='submit' value='SUBMIT'/>
    </form>
</body>

process.php

process.php

$name = $_GET['name'];
$age = $_GET['age'];

$file_handle = fopen("testFile.txt", "w");
$file_contents = "name:" . $name . "age:" . $age;

fwrite($file_handle, $file_contents);
fclose($file_handle);
print "file created and written to";

我该怎么做?

推荐答案

谢谢.我使用此 http://www.redips.net/php/解决了此问题写入日志文件/

这篇关于编写文本文件php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆