-3

syntax error, unexpected 'for' (T_FOR), expecting identifier (T_STRING)

  public function for($user)
    {
        $this->user = $user;

        return $this;
    }
brombeer
  • 8,716
  • 5
  • 21
  • 27
MrVirussS
  • 23
  • 1
  • 4

1 Answers1

3

for is a reserved keyword in php (and most other languages). This means that you can't use it as a function or variable name. If you rename your function to something like setUser it should all be fine.

public function setUser($user) {
    $this->user = $user;
    return $this;
}

You can find a list of other reserved keywords here: http://php.net/manual/en/reserved.keywords.php

Dirk Scholten
  • 1,013
  • 10
  • 19