我一直想用php的fopen打开一个文件。

        $db_ausgaenge = "statuseing.php";
        $dout = fopen($db_ausgaenge, "x+");
        print $dout;
        print(shell_exec('whoami'));
        print(shell_exec('pwd'));
        print(shell_exec('id'));
        fwrite($dout, $out);
        fclose($dout);

Warning: fopen(statuseing.php): failed to open stream: File exists in /var/www/html/zufallsgenerator.php on line 33

我检查了以下项目:
chmod for statusing.php 0777
所有者是www data和groud www data
脚本作为用户www数据运行
组是uid=33(www data)gid=33(www data)groups=33(www data)
pwd是/var/www/html
脚本要打开的路径是正确的
选中了phpinfo()中显示的php.ini中的openbase dir,添加了/var/www/html,但php并不关心它。
打开\u basedir=/var/www/html/
在后台程序重新加载并通过systemctl重新启动apache2之后,没有任何更改,phpinfo()没有显示配置中给定的路径。通过init 6重新启动系统也没有生效。

最佳答案

Stasuuth.PHP已经存在。
请参阅手册(http://php.net/manual/en/function.fopen.php)-以x或x+模式打开时显示:Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE

关于php - PHP无法读取文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39947240/

10-14 18:43
查看更多