【发布时间】:2012-10-31 10:14:13
【问题描述】:
我在 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 工作方面不是最有经验的人。
【问题讨论】: