【发布时间】:2015-01-10 20:10:06
【问题描述】:
我有一个从批处理文件运行的 php 脚本。测试这是否有效的最佳方法是什么。
目前BAT文件有这个:
c:\php\php.exe -f c:\www\somedomain\customcode\automated_scripts\simple_email.php
我尝试双击批处理文件以查看它是否会运行 php 脚本,但里面的代码似乎没有做任何事情。
该文件中使用的代码示例:
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "Mickey Mouse\n";
fwrite($myfile, $txt);
$txt = "Minnie Mouse\n";
fwrite($myfile, $txt);
fclose($myfile);
和
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: myemail@domain.com' . "\r\n" .
'Reply-To: anotheremaik@someoneelse.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail('anotheremaik@someoneelse.com',"hello test","testing msg",$headers);
未发送电子邮件,未在服务器上创建文件...有更好的方法来测试或输出一些调试数据吗?
【问题讨论】:
-
我认为您的选择实际上只是电子邮件或将信息记录到文本文件。我很想看看其他人对此有何建议。
标签: php batch-file scheduled-tasks