我有以下在 cron 中运行的代码,
<?php
$_SERVER['DOCUMENT_ROOT'] = dirname(__FILE__);
$directory = $_SERVER["DOCUMENT_ROOT"]."/cron/";
$file = "register_warranty_". date("dMY") .".csv";
$filepath = $directory.$file;
if(!file_exists($filepath))
{
$fp = fopen($filepath, "w+");
fwrite($fp, "Title, Initials, Surname, HomeTel, Mobile, HouseNumber, Address, Address2, Town, Postcode, NewlyBuiltHome, InstallationDate, Houseowner, InstallersName, InstallersEmail, InstallersMobile, InstallersGasSafeNumber, BusinessName, BusinessAddress, BusinessAddress2, BusinessTown, BusinessRegion, BusinessPostcode, BusinessGasSafeNumber, BusinessEmail, SuppliersName, Model, serial, MaintenanceContract, ExpiryDate, Donotwishtobecontactedviapost, Donotwishtobecontactedviatelephone, Donotwishtobecontactedviaemail, Donotwishtobecontactedviasms\n");
fclose($fp);
}
?>
在运行 cron 时收到的 Cron 电子邮件中 - 我收到以下错误,
第 1 行:?php:没有这样的文件或目录
第 3 行:意外标记附近的语法错误$_SERVER['DOCUMENT_ROOT'] = dirname( FILE );'('
line 3:
我是不是做错了什么,我对 Cron 工作不是最有经验的。