Press enter to see results or esc to cancel.

Unexpected ‘function’ (T_FUNCTION) on line 1

Were you presented with the following PHP error after uploading a WordPress theme to a web server using FileZilla ftp client?

Parse error: syntax error, unexpected 'function' (T_FUNCTION) in some-theme-filename.php on line 1

If you open the file that’s mentioned in the error locally you won’t find anything unusual. The key is to download the same file from your server and open it. Is all the code compressed into line 1 of this file? If so, read on!

FileZilla is configured to auto-determine what transfer mode to use (ASCII or Binary) when uploading files. However, depending on feedback from the server, it sometimes gets things wrong and uploads files using the wrong (ASCII) transfer mode, compressing all code into line 1 of each file in the process.

The solution to this problem is quite simple. Upload the files again, but this time with the transfer mode set to Binary. In fact, whenever you use FileZilla or any other ftp client for that matter, the transfer mode needs to be set to Binary. In FileZilla, to set the transfer mode to Binary, click on Transfer->Transfer Mode->Binary in the top menu bar.

Transfer mode binary

When uploading, make sure you overwrite the previous files so that your transfer mode changes take effect.

Comments

1 Comment

dev

Many thanks,it was all I was looking for.Wondering what happened to my code which was working fine on localhost but started giving problem as soon as I uploaded it to the server.


Leave a Comment