Parse error: Syntax error, unexpected end of file in my PHP code

后端 未结 16 1722
孤城傲影
孤城傲影 2020-11-22 05:27

I got an error:

Parse error: syntax error, unexpected end of file in the line

With this code:


    

        
16条回答
  •  误落风尘
    2020-11-22 05:38

    I had the same error, but I had it fixed by modifying the php.ini and / or editing the PHP file!

    There are two different methods to get around the parse error syntax.

    Method 1 (Your PHP file)

    Avoid in your PHP file this:

    
    

    Make sure you put it like this

    
    

    Your code contains

    NOTE: The missing php after !

    Method 2 (php.ini file)

    There is also a simple way to solve your problem. Search for the short_open_tag property value (Use in your text editor with Ctrl + F!), and apply the following change:

    ; short_open_tag = Off
    

    to

    short_open_tag = On
    

    According to the description of core php.ini directives, short_open_tag allows you to use the short open tag () although this might cause issues when used with xml ( will not work when this is enabled)!

    NOTE: Reload your Server (like for example: Apache) and reload your PHP webpage in your browser.

提交回复
热议问题