我有以下功能來計算工作日計算中的星期日。它在我的測試服務器上運行,它是在Mac上運行的MAMP。當我將代碼移動到運行LAMP的Unbuntu服務器時,它停止工作(表現爲頁面沒有加載任何東西)。MAMP與Ubuntu服務器之間的語法差異
我無法弄清楚爲什麼,並嘗試了單引號和雙引號的所有不同組合。
功能是: -
// function to account for Sundays, and public holidays. Add holiday dates in $holidayDays variable
function get_next_business_date($from, $days) {
$workingDays = [1, 2, 3, 4, 5, 6]; # date format = N (1 = Monday, ...)
$holidayDays = ["*-12-25","*-12-26", "*-01-01", "2014-12-24"]; # variable and fixed holidays
$from = new DateTime($from);
while ($days) {
$from->modify("+1 day");
if (!in_array($from->format('N'), $workingDays)) continue;
if (in_array($from->format('Y-m-d'), $holidayDays)) continue;
if (in_array($from->format('*-m-d'), $holidayDays)) continue;
$days--;
}
return $from->format("Y-m-d"); # or just return DateTime object
}
$today = date("Y-m-d", strtotime("today"));
$tomorrow = get_next_business_date("today", 1);
$twodays = get_next_business_date("today", 2);
$yesterday = date("Y-m-d", strtotime("yesterday"));
我迷路了,爲什麼這可能是。
PHP中的「頁面無法加載任何內容」或「死亡白屏」意味着您需要檢查錯誤日誌。總是在開發和測試代碼時,使用'error_reporting(E_ALL); ini_set('display_errors',1);'在腳本的頂部。錯誤將被詳細列出。 – 2014-10-11 12:10:34
你確定這是與這個功能有關嗎?也許這是一個權限問題呢? – Fluffeh 2014-10-11 12:10:40
review /var/log/apache2/error.log – 2014-10-11 12:11:17