PHP Parse Error: syntax error unexpected $end wrong solution

  • 2020-05-17 04:59:34
  • OfStack

Writing php program these days, I feel that many places are not as convenient as asp, asp.Net, jsp, session, session_start(); , file jump header is also not convenient...

Maybe it is some features of php that I am not familiar with, but if I write too much, I will gradually get used to it...

Here is a code compilation debugging problem, the error is as follows:

Parse error: syntax error, unexpected $end in D:\xampp\htdocs\guestBook\guestBook.php on line 330

If you look at the 330 lines of code, the last line of code, what's wrong with that? google searched and found:

In PHP 5, the following error may appears as an error entry in Apache error log or simply displays on PHP web page, even if calling to php scripts with php_info() works perfectly and successfully returns information on PHP configurations:

Parse Error: syntax error, unexpected $end in... . scripts. php on line...

The error may caused by a missing curly bracket in PHP script coding. Beside, it may also caused by error in PHP coding in class definition, as in PHP, a class definition cannot be broke up and distributed into multiple files, or into multiple PHP blocks, unless the break is within a method declaration.

But more commonly, the error is often caused by the use of Short Open tags in PHP,

To use short open tags, it must be enabled in PHP.INI. Search for short_open_tag in PHP.INI, and change the value to On. The line should look line:

short_open_tag = On

Are you kidding me about my English? Look at the other search, all don't get to the point, then look at the English, although can not be translated, roughly means see clear:

The error occurred using a short tag, short_open_tag = On in php.ini

The original Parse error hint 1 is a syntax error, using an open label, the statement does not end is programming the basic 1 error, such as did not pay attention to the end of the statement plus ";"; Or if () {... I forgot "}" after "}"; < ?php...? > Forget?" > ". Check the code carefully, and sure enough, "}" is left out in the first place. The modified program runs normally

Related articles: