Take the 2-minute tour ×

I don't know if this has happended to some of you developers before but sometimes when I reload a script on the browser, I receive this php error:

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

It will point to different line numbers on my script for every time it does appear and if I realod the script on the browser, then it loads the page successfully with no errors.

My question is though that why does this error sometimes appear when I load the script on the browser?

share|improve this question
it happen when we do not close {} properly –  NullPoiиteя Dec 24 '12 at 20:23
It could happen with some FTP servers when server (Apache, IIS) tries to read a file which is being uploaded. –  Salman A Dec 24 '12 at 20:26
as other users have mentioned, it's because you have forgotten to close a '}', but since you say that after refreshing the page, the same script works OK without changing the code, then it may be the case that you have a page which is including inside your code and in some special conditions(like checking a session variable) it will be included. the first time because the variable is not set, the page will be included and the error will be shown, but for the second time, when you refresh the page, because the variable is set, the page will not be included and there will be no errors. –  EhsanT Dec 24 '12 at 20:35
add comment

closed as too localized by Till Helge, rdlowrey, PeeHaa, Alexander, Ocramius Mar 3 '13 at 15:55


2 Answers

up vote 2 down vote accepted

This happens a lot to me when I'm developing websites, usually it's because the file hasn't completely uploaded via FTP.

If this is the case, try waiting a bit longer before accessing the page in your browser.

share|improve this answer
You are right I believe, it is because the server is very slow today and I think I am refreshing the script too quickly because I don't think it is overwritten the file after I have made changes before I have done the refresh. –  user1881090 Dec 24 '12 at 21:41
add comment

The Parse error: syntax error, unexpected $end in / means:

That you have forgotten to close your PHP script with } tag.

Check if you have left your script open somewhere. If you want, you could always count all the { and } and you will find out that there is at-least one more, or less. :) depends on how you look at it.

share|improve this answer
It is definitly not a bracket issue, I checked the brackets and like I said when I refresh the page, the error dissapears and the app works fine –  user1881090 Dec 24 '12 at 21:39
add comment
