Forums / Zen Cart Code Suggestions / Corrections for obscure "syntax error, unexpected end of file" errors

Corrections for obscure "syntax error, unexpected end of file" errors

Locked

Views: 81

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
18 Nov 2012, 3:42 PM
#1
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Corrections for obscure "syntax error, unexpected end of file" errors

This one had me pulling my hair out for a while. I've got a localhost installation of my hosted website; upgraded both to PHP version 5.4. All's going well, then I noticed that one of my pages went blank on my localhost version with the "syntax error, unexpected end of file" error in the debug*.log file. When I checked my hosted version, all's fine. The only difference appears to be that the localhost installation is running on Windows and my hosted version is running on linux.

After much probing and prodding, the errant line was the one highlighted in red:

<?php/*-bof-c-minacct
<?php if (!$flagDisablePaymentAddressChange) { ?>
*/ ?>

The fix was to add a space between the <?php and the /*!

<?php /*-bof-c-minacct
<?php if (!$flagDisablePaymentAddressChange) { ?>
*/ ?>

I'll be updating my "Minimum Customer Account Information" to make this change, but thought that others might be interested as well. Note that this code ran fine on my previous XAMPP installation using PHP 5.2.17, so a change must have been introduced in the interim that affects Windows.

Update: I'm also updating all my changes to make sure that there is not only a space after each <?php but also a space before each ?>.

18 Nov 2012, 6:19 PM
#2
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Corrections for obscure "syntax error, unexpected end of file" errors

Aye, I've seen this behavior in PHP 5.4 (not specifically with your plugins). Both in my WAMP x64 and in my CentOS x64 environment. I've gone to doing the same thing, always including the extra spaces inside the php block. Strangely, I've also needed to sometimes add an extra newline after the closing tag to get a newline in generated HTML.

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

19 Nov 2012, 12:45 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Corrections for obscure "syntax error, unexpected end of file" errors

Just a note to confirm: Zen Cart doesn't use the incorrect syntax (ie: <?php/* without the space) anywhere in its core files.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Nov 2012, 12:44 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: Corrections for obscure "syntax error, unexpected end of file" errors

Thanks for the confirmation, DrByte ... I didn't think it was an issue with the core code and placed the note here because I couldn't find a better home for it!