How do I find files that may have extra line breaks or whitespace after the ?> in a PHP file?

Created: Aug 28, 2009 12:20 AM
Last Modified: Aug 17, 2011 11:15 AM
Rated 5 stars 1 Rating | 0 Comments
When a PHP script has extra whitespace after the final ?> a headers errors can result.  In the normal operation of your X-Cart store this can cause a message to display when adding products to the cart, or clicking links on your store:

If the page is not updated in 2 seconds, please follow this link.

When using modules such as the One Page Checkout that transfer XML data between the browser and the server this whitespace can cause the application to fail.  To fix this:

1. Download this script: find_whitespace.zip (1.16 KB)
2. Unzip the find_whitespace.php file and upload it to the root of your X-Cart store.
3. Open this script in a  web browser.  Example: http://www.yourstore.com/find_whitespace.php

The page will display all files in your X-Cart directory that have extra space after the final ?>




You will need to open these files in a text editor and remove the whitespace.  Then re-upload the file to your website.

File with extra whitespace:



Removed:




If your FTP client adds the whitespace again after removing it you will need to upload the file in binary mode (see your FTP client help to change your upload settings).  This can be caused by having both Windows \r and Linux \n line breaks in the file.

After making the change run the find_whitespace.php page again to insure the file(s) have been successfully updated and the whitespace removed.

Still Have Questions?

If you are unable to find a solution in the knowledgebase please open a support ticket for a personal response from the support desk.

Rate or comment on this article

Rate This Article (Select a star)

Select Rating  
Change rating to 1 Change rating to 2 Change rating to 3 Change rating to 4 Change rating to 5

Add Comment

You must be logged in to add a comment