Parse error: syntax error, T_ENCAPSED_AND_WHITESPACE, expecting

in the line $day = date('j', strtotime($event['event_start']));

 private function _createEventObj() { $arr = $this->_loadEventData(); $events = array(); foreach ( $arr as $event ){ $day = date('j', strtotime($event['event_start'])); try { $events[$day][] = new Event($event); } catch ( Exception $e ) { die ( $e->getMessage()); } } return $events; } 

It seems that all brackets are closed. Please, help. The full code is posted on http://pastebin.com/ , called Calendar. I'm really looking forward to more help.

  • Partially decided, but. Put braces on the line, like this: $ day = date ('j', strtotime ({$ event ['event_start']})); the error has now moved to the very end of the code, to the line where the closing one is -?> Error: syntax error, unexpected $ end in - Kirill Seleznev
  • The partial solution is exactly wrong. In this line, I do not see the syntax. The only thing that came to mind was that you either copied not something that is, or the "strtotime" function is not with you. In the sense that I know what should be. Give the result of this code (instead of the problematic line) die (var_dump (function_exists ('strtotime'), $ event ['event_start'])); - Sh4dow 2:58 pm
  • one
    @ Sh4dow, a non-existent function causes an error of a non-existent function. Has anything copied from external sources in this code? There may be non-printable characters? - etki
  • It is this piece of code that is 100% working (I have this training project :): I put it in the code, copying one to one into the IDE from the question, everything works! Look for a problem higher in the class, somewhere too smart or give a code of the class Calendar to us for a test, although it is rather long. - MDJHD
  • Well, yes, if you copied from the book, and not stuffed by hand, then perhaps, as @Fike says, left characters got lost, which make the interpreter crazy - MDJHD

1 answer 1

Remove all spaces before FORM_MARKUP; (266th line)

The "here document" syntax does not allow spaces before the closing identifier

 echo <<<END Здесь используется синтаксис "here document" для вывода нескольких строк с подстановкой переменных $variable. Заметьте, что закрывающий идентификатор должен располагаться в отдельной строке. никаких пробелов! END; 

Because of this error, you have the entire document after this line considered to be part of the here document.

  • Thank you very much @VenZell, since yesterday, steamed c this problem. - Kirill Seleznev