Skip to content


PHP Error – Parse error: syntax error, unexpected $end in

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

Don't you love it when the line number indicated for an error message is the last line in the file which obviously has no error? I spent twenty minutes on this one last night.

Check for unmatched braces, brackets, parentheses or PHP tags. Nope.

Try echoing line numbers to see where execution stops. In this case no output was generated even with an echo on line #1.

Create a new file and pasted the code as Unix ASCII. Still no change.

Check PHP settings. short_open_tag is disabled by default.

[root@atlas ~]# php -i | grep short_open_tag
105:short_open_tag => On => On

Create .htaccess file:

php_flag short_open_tag on

Page loads with no errors.

Do a search for short open PHP tags in the source and replace with default tags.

Find

<?

Replace

<?php

Turn short_open_tag back off in .htacess:

php_flag short_open_tag off

Page still loads with no errors.

Popularity: 34% [?]

Posted in Development, PHP.


2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. zeyad shorman says

    i have error on my php code ,the error is Parse error: syntax error, unexpected $end in E:\AppServ\www\constant.php on line 17

    Three plus five

    three plus five
    demonstrate use of number variables
    $x $y = $sum
    $x – $y = $dif
    $x * $y = $prod
    $x / $y = $quotient
    HERE;
    ?>

  2. zeyad shorman says

    this one $x $y = $sum
    $x – $y = $dif
    $x * $y = $prod
    $x / $y =$quotient
    HERE;
    ?>



Some HTML is OK

or, reply to this post via trackback.