• Register
0 votes
38 views

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

inserting a code snippet similar to the original one:

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

<?php

//my php functions goes here

    <h3> some other html </h3>

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

        if ($item > 20) {
          break;
        }
        echo $item;
    }
?>

</body>
</html>

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

 

 

10 7 2
6,060 points

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 6 views
6 views
This error continiously showing in my script. How to solve this error.
asked Oct 3 Daniel Anderson 4k points
0 votes
1 answer 8 views
8 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 22 hours ago psandprop 1.9k points
0 votes
1 answer 8 views
8 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 Sheeza 2.9k points
0 votes
1 answer 6 views
6 views
I am finding difficulty to get radio button value in php without submit.
asked Oct 5 Daniel Anderson 4k points
0 votes
1 answer 178 views
178 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 Gavin 15.3k points