3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function period_to_timestamps($period) { switch($period) { case "last_7_days": $start = strtotime('-7 days'); $end = strtotime('now'); break; case "this_month": $start = strtotime('first day of this month'); $end = strtotime('now'); break; case "last_month": $start = strtotime('first day of last month'); $end = strtotime('last day of last month'); break; case "this_year": $start = strtotime('01-01-' . date('Y', strtotime('now'))); $end = strtotime('now'); break; case "last_year": $start = strtotime('first day of last year'); $end = strtotime('last day of last year'); break; default: $start = strtotime('now'); $end = strtotime('now'); } return array($start, $end); } var_dump(period_to_timestamps('last_7_days');
Output for 5.3.0 - 5.4.29
Parse error: syntax error, unexpected ';' in /in/P8hTg on line 33
Process exited with code 255.