我有以下功能来计算工作日计算中的星期日。它在我的测试服务器上运行,它是在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