-1

EDIT:

My mate pointed out after looking at it for a few hours that it was a wrong bracket


Problem: I am getting constant errors while using this.

Error:
mod_fcgid: stderr: PHP Parse error: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) in /var/www/clients/client**/web***/web/****/data.php on line 101

Code: Here is a snippet of the code (the rest of the days is not relevant for the code)

class Day {
    function getDag($day) {
        $days = array();
        $whatdayisit = date("w");
        if($day == 1) {
            if ($whatdayisit == 1){
            array_push($days, strtotime("Monday"));
            array_push($days, strtotime("Monday + 1 day"));
            }
            else {
            array_push($days, strtotime("next Monday"));
            array_push($days, strtotime("next Monday + 1 day"));
            }
        }
        return $days;
}

Did I do research? Yes I did research. I searched for a long time on google and stackoverflow, but I just couldn't find an solution that suited my exact problem.

2 Answers2

0

You're missing the closing bracket at the end of your function.

class Day {
    function getDag($day) {
        $days = array();
        $whatdayisit = date("w");
        if($day == 1) {
            if ($whatdayisit == 1){
            array_push($days, strtotime("Monday"));
            array_push($days, strtotime("Monday + 1 day"));
            }
            else {
            array_push($days, strtotime("next Monday"));
            array_push($days, strtotime("next Monday + 1 day"));
            }
        }
        return $days;
    }
}
Indy
  • 391
  • 1
  • 13
  • 19
0

You are missing the closing curly brace for your function definition. Try this:

class Day {
    function getDag($day) {
        $days = array();
        $whatdayisit = date("w");
        if($day == 1) {
            if ($whatdayisit == 1) {
                array_push($days, strtotime("Monday"));
                array_push($days, strtotime("Monday + 1 day"));
            } else {
                array_push($days, strtotime("next Monday"));
                array_push($days, strtotime("next Monday + 1 day"));
            }
        }
        return $days;
    }
}
nick.graziano
  • 677
  • 6
  • 12