Today we start a new series of articles on the ServerGrove Blog about common problems (and their solutions) with PHP when uploading to production servers, specially on VPS and shared hosting servers.  We see some of these problems with our clients, and while we have some articles on the KB, and we add those that we find and are missing, it also helps give them some more visibility through the Blog.

We hope you find these articles useful. Let us know what you think.

Today’s common problem: PHP Parse error:  syntax error, unexpected T_STRING in /path/project/apps/frontend/modules/module/templates/indexSuccess.php on line 1

The path above is an example of a template file on a symfony project. If your files work fine in your development server, and when you upload it to the production server you get this error, it is quite possible that the production server has PHP short tag enabled and that your HTML template starts with <?xml. When short open tag is enabled, PHP treats <?xml as  <? to initiate parsing PHP code. Although it is suggested that developers do not use  PHP short open tags ( <? ?> instead of <?php ) many open source applications already do.

There are two possible solutions to this problem:

a) Disable the PHP short open tag feature. You can do this by adding the following line to a .htaccess file in your document root or httpdocs directory

php_flag short_open_tag “0”

b) Remove the <?xml?> tag from your HTML (XHTML in this case) template. Although this option is less desirable, we still include as one.

You can find more information about it on the PHP manual page.