Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-fopen log_post.txt无法打开流:没有这样的文件或目录_Php_Html - Fatal编程技术网

PHP-fopen log_post.txt无法打开流:没有这样的文件或目录

PHP-fopen log_post.txt无法打开流:没有这样的文件或目录,php,html,Php,Html,警告:fopen(log_post.txt):无法打开流:第3行的C:\xampp\htdocs\MyApp\public\index.php中没有此类文件或目录 无法打开文件 公用文件夹中的Myindex.php: <?php $File = "log_post.txt"; $fh = fopen($File, 't') or die("can't open file"); fwrite($fh, "\n"); #$headers = apache_request_headers(

警告:fopen(log_post.txt):无法打开流:第3行的C:\xampp\htdocs\MyApp\public\index.php中没有此类文件或目录 无法打开文件

公用文件夹中的My
index.php

<?php
$File = "log_post.txt"; 
$fh = fopen($File, 't') or die("can't open file"); 
fwrite($fh, "\n"); 
#$headers = apache_request_headers(); 
#foreach ($headers as $h => $v)
#   fwrite($fh, "$h: $v\n");
#fwrite($fh, print_r($HTTP_RAW_POST_DATA,1));
fclose($fh);
require_once 'Framework/SiteHandler.php';

Zend_Controller_Front::getInstance()
    ->setControllerDirectory('../application/controllers')
    ->throwExceptions(false)
    ->dispatch();
?>

使用
fopen($File,'a')
而不是
fopen($File,'t')
函数
fopen
没有模式
t
。您需要指定一种模式,如w、a、r等,然后附加t以使用行尾转换模式。使用类似以下内容:

fopen($File, "rt");
您可以将
rt
更改为任何有效的php模式,并在最后更改
t
,例如
at
wt
r+t


有关信息,请参见此处:

您是否具有正确的权限?该文件存在吗?该文件存在,是的,我有正确的权限。Thx它工作了,但有办法让旧网站回来吗?我的意思是,在我使用Zend之前,我对我的网站有正常的访问权限,现在我只得到一种“代码”。我也有一个home.php,但是我知道如何使用它。我是新来的我忽略了这个,对不起。当您将模式指定为fopen时,您需要一个实模式并附加t以使用文本转换模式。换句话说,你不能只用t。您需要类似于
rt
wt
at
的内容。请看这里:在fopen中使用相对路径也是错误的。请看这里的解释和解决方案:嗯,thx。我现在用rt。但有没有办法让我的“旧”网站恢复原状,就像我使用Zend Framework之前一样?当我访问ma网站时,我得到了这个imgur.com/vtxwi1hs开始一个新问题。问题不是用来回答多个问题的。还可以使用
http://
链接链接,如下所示:在fopen中使用相对路径也是错误的。有关解释和解决方案,请参见此处: