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

后端 未结 16 1656
孤城傲影
孤城傲影 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:30

    I had the same error, but I had it fixed by modifying the php.ini file.

    Find your php.ini file see Dude, where's my php.ini?

    then open it with your favorite editor.

    Look for a short_open_tag property, and apply the following change:

    ; short_open_tag = Off ; previous value
    short_open_tag = On ; new value
    
    0 讨论(0)
  • 2020-11-22 05:32

    Avoid this as well <? } ?> make sure you put <?php } ?>

    0 讨论(0)
  • 2020-11-22 05:35

    If your using parse_ini_file($file) or a routine is rading an .ini file, check if you data is quoted in the ini file. Unquoted data will cause this error. Ex; data1=test will cause the error, data1="test" will not.

    0 讨论(0)
  • 2020-11-22 05:36

    You can't divide IF/ELSE instructions into two separate blocks. If you need HTML code to be printed, use echo.

    <html>
        <?php
            function login()
            {
                // Login function code
            }
            if (login())
            {
                echo "<h2>Welcome Administrator</h2>
                <a href=\"upload.php\">Upload Files</a>
                <br />
                <a href=\"points.php\">Edit Points Tally</a>";
            }
            else
            {
                echo "Incorrect login details. Please login";
            }
        ?>
        Some more HTML code
    </html>
    
    0 讨论(0)
  • 2020-11-22 05:37

    Just go to php.ini then find short_open_tag= Off set to short_open_tag= On

    0 讨论(0)
  • 2020-11-22 05:38

    You should avoid this (at the end of your code):

    {?>
    

    and this:

    <?php}
    

    You shouldn't put brackets directly close to the open/close php tag, but separate it with a space:

    { ?>
    <?php {
    

    also avoid <? and use <?php

    0 讨论(0)
提交回复
热议问题