PHP文件不写入当前目录? [英] PHP file doesn't write to current directory?

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

问题描述

我有一个网络的主机是一个PHP文件如下:

I have a PHP file on a web-host that is as follows:

<?php

file_put_contents('test.txt','TEST');    
echo 'OK';

?>

但文件的test.txt 当我从浏览器中执行该页面未创建。为什么不呢?它是一个权限问题?

But the file test.txt is not created when I execute the page from a browser. Why not? Is it a permissions issue?

推荐答案

是PHP的医生说。

如果文件名不存在,则创建该文件。否则,现有文件被覆盖,除非FILE_APPEND标志被设置

If filename does not exist, the file is created. Otherwise, the existing file is overwritten, unless the FILE_APPEND flag is set.

这只是如果你写有该文件夹的权限....尝试

That is only if you write have permission on that folder .... try

error_reporting(E_ALL);
ini_set("display_errors", "on");

if (! is_writable(__DIR__)) {
    trigger_error("I don't have permission");
}

file_put_contents('test.txt', 'TEST');

这篇关于PHP文件不写入当前目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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