以下是我的代码,
test.php的
<?php
$prefixnew = "testnew";
$file1 = fopen("testnew.txt","w");
$content_wr_g = "Test sitest"
fwrite($file1,$content_wr_g);
fclose($file1);
?>
test.bat的
@ECHO off
C:\wamp\bin\php\php5.3.13\php.exe -f "C:\...\test.php"
popd
更新
当我直接从浏览器运行(test.php)时,它正常工作。如果我从预定的任务中运行,它就无法正常工作。
我非常清楚创建任务的任务调度程序步骤。当我运行一组更新查询或删除查询意味着,它运行良好。
当我有fopen(), fwrite()
等代码时,它无效
答案 0 :(得分:0)
不使用相对路径,而是使用文件的绝对路径:
$file1 = fopen(__DIR__.'/testnew.txt', 'w');
我假设您正在使用>= PHP 5.3
,如果没有尝试:
$file1 = fopen(dirname(__DIR__).'/testnew.txt', 'w');