繁体   English   中英

fopen(),fwrite()函数在php中不起作用

[英]fopen(), fwrite() function is not working in php

下面是我的代码,

test.php

<?php
$prefixnew = "testnew";
$file1 = fopen("testnew.txt","w");
$content_wr_g = "Test sitest"
fwrite($file1,$content_wr_g);
fclose($file1);
?>

测试棒

@ECHO off


C:\wamp\bin\php\php5.3.13\php.exe -f  "C:\...\test.php"


popd

更新

当我直接从浏览器运行(test.php)时,它工作正常。 如果我从计划任务运行,则无法正常工作。

我非常了解创建任务的任务计划程序步骤。 当我运行一组更新查询或删除查询意味着,它运行良好。

当我有fopen(), fwrite()等代码时fopen(), fwrite()它无法正常工作

代替使用相对路径,而使用文件的绝对路径:

$file1 = fopen(__DIR__.'/testnew.txt', 'w');

我假设您正在使用>= PHP 5.3 ,如果不尝试:

$file1 = fopen(dirname(__DIR__).'/testnew.txt', 'w');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM