• Register
0 votes

I was adding some php code inside a simple HTML page.

inserting a code snippet similar to the original one:

    <title> Page Title </title>
    <p> Paragraph contents </p>


//my php functions goes here

    <h3> some other html </h3>

//second php block
    for ($item = 5; ; $item++) {

        if ($item > 20) {
        echo $item;


Does anyone know the possible reason of such a silly problem?



10 7 2
6,060 points

Please log in or register to answer this question.

1 Answer

0 votes

In my case I had to do some fixing on my closing php tags, such as Instead of writing


write this

php ?>

->Mixing of PHP and HTML is slightly confusing so it is recommended to notice some differences between writing these also:

//wrong way

<? } ?> 

//right way

<?php ?>


-> short_open_tag on your php.ini file could be another reason of throwing that kind of error.

 set it to:

short_open_tag= On

The error "unexpected end of file" usually means you have a php code block that is not properly closed or somehow is not terminated yet. So the code is unable to be parsed anyway.

Another piece of code is still missing until end of file which is expected by the PHP compiler.

Hope that helps!

11 6 4
34,950 points

Related questions

0 votes
1 answer 12 views
This error continiously showing in my script. How to solve this error.
asked Oct 3, 2020 Daniel Anderson 4k points
0 votes
1 answer 10 views
Problem I am facing some strange behavior of PHP. I am new in PHP, but it are not my first lines in PHP. For some reason I am getting: Parse error: syntax error, unexpected end of file in the line Here is the adapted code: <html> <head> </head> <body> <?php function authenticate() ... Tally</a> <?php} else { echo "Wrong login details. Please try again"; } ?> <!-- HTML stuff --> </body> </html>
asked Dec 7, 2020 alexh 2.2k points
0 votes
1 answer 16 views
Problem: Hello Kodlogs, I am working on a program that runs more on control expressions and I got a surprised error of this nature: syntax error, unexpected end-of-input, expecting keyword_end Can you help me out?
asked Nov 4, 2020 Festus James 360 points
0 votes
2 answers 75 views
I am a beginner to python and am at the moment having trouble using the command line. I have a script test.py (which only contains print("Hello.")), and it is located in the map C:\Python27. In my system variables, I have specified python to be C:\Python27 (I have ... but when I do so I get this: File "<stdin>", line 1 python test.py ^ SyntaxError: invalid syntax What is wrong? Thanks in advance!
asked Oct 25, 2020 psandprop 2.4k points
0 votes
1 answer 16 views
Problem: I am trying to get the value Contact_LastName from the HTML pasted below but I am getting the following error Uncaught Error: Syntax error, unrecognized expression: div #*Emails are not allowed* Javascript: $('.rdContact').off("click").on("click", function (e) { e ... class="btn btn-success"> <input type="button" value="Cancel" id="btnCancelContact" class="btn btn-default"> </div> </div>
asked Dec 7, 2020 sasha 5.3k points
0 votes
1 answer 12 views
Problem: Hi there, I am programming in c++ and I am working with variables. I am noob ofcourse so encountering multiple errors from time to time. Right now, my compiler is giving me declaration syntax error.I have very little knowledge about the types of errors in c++. Can anybody tell me how to resolve this error?
asked Oct 13, 2020 Code Learner 5.5k points
0 votes
1 answer 25 views
I am finding difficulty to get radio button value in php without submit.
asked Oct 5, 2020 Daniel Anderson 4k points
0 votes
2 answers 379 views
Problem: Hello guys, I am running this code in visual code but dont know why the error ic coming can you please check the error of if__name__ ==__main__invalid syntax. def main(): generateRandomNumbers() def generateRandomNumbers(): print ('Test') si_ze = 0 nameLength=0 ... == "__main__" main() Getting Syntax error if name == main ^ SyntaxError: invalid syntax Process finished with exit code 1
asked Jun 9, 2020 Gavin 15.3k points
1 vote
1 answer 36 views
Problem: Hello guys, While solving basic condition problem in python I am trying to implement the below logic but don't know python is throwing error, the invalid syntax for no reason,below is the code. day = int(input("Enter the day of week:")) vacation = (input("Enter is vacation? [True| ... 00") else: if day == 0 or day == 6: print("Alarm is off") elif: print("10:00") Dont know what is wrong.
asked Jun 7, 2020 Gavin 15.3k points
1 vote
1 answer 679 views
Problem: I&rsquo;ve written a basic python program and trying to compile and run it. Unfortunately, the program is not working for me. find the attached snippet below of my program: def multiple_table(n): for i in range(1,16): print(' {0} x {1} = {2} '.format( ... . Could you please give a review into my codes and find out the bug? I am looking forward to having a legit solution from you. Thanks.
asked Apr 21, 2020 Gavin 15.3k points