PHP将变量写入txt文件 [英] PHP Write a variable to a txt file

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

问题描述

我正在尝试从查询字符串中获取一个变量并将其写入文本文件. 我已经这样尝试过:

I am trying to get a variable from the query string and write it to a text file. I have tried like this:

<?php
$content=( $_GET['var'] );
echo $content;
$file = fopen("etlLOG.txt","w+");
echo fwrite($file,$content);
fclose($file);
?> 

我收到以下错误:

警告:fopen(etlLOG.txt)[function.fopen]:无法打开流:在第8行的E:\ Users \ george \ listener.php中,权限被拒绝

Warning: fopen(etlLOG.txt) [function.fopen]: failed to open stream: Permission denied in E:\Users\george\listener.php on line 8

警告:fwrite():在第9行的E:\ Users \ george \ listener.php中,提供的参数不是有效的流资源

Warning: fwrite(): supplied argument is not a valid stream resource in E:\Users\george\listener.php on line 9

警告:fclose():在第10行的E:\ Users \ george \ listener.php中,提供的参数不是有效的流资源

Warning: fclose(): supplied argument is not a valid stream resource in E:\Users\george\listener.php on line 10

推荐答案

看起来Web服务器无权访问该文件.如此使用的ftp fopen提供了正确的凭据和路径,最后我确实设法访问和编辑了文件

Well it appears that the web server does not have access to that file. So used ftp fopen provided the correct credentials and paths and finally i did managed to access and edit the file

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

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