如何使用file_put_contents()将内容放在不同目录中的文件中?

时间:2014-02-13 19:08:04

标签: php

我的网站上有一个文件内的表格。此文件位于名为“blog”的目录中,但我希望我的file_put_contents转到我网站上的主页。这就是我所拥有的:

file_put_contents("enm185.tk/index.php","example code")

这是我的文件,位于enm185.tk/blog/index.php。有没有办法让这个工作?

1 个答案:

答案 0 :(得分:3)

您可以使用绝对路径,也可以使用..上一个目录:

file_put_contents('../index.php', 'example code');