PHP file doesn't write to current directory?

前端 未结 2 1626
醉话见心
醉话见心 2021-01-23 22:28

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


But the file

2条回答
  •  半阙折子戏
    2021-01-23 22:48

    yes the PHP Doc Says

    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');
    

提交回复
热议问题