Zen Cart Logo
Forums / General Questions / When looking for extra lines and spaces in php files...

When looking for extra lines and spaces in php files...

Locked

Views: 1,858

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
27 Aug 2009, 2:44 AM
#1
lieven23 avatar

lieven23

Zen Follower

Join Date:
Aug 2008
Posts:
340
Plugin Contributions:
0

When looking for extra lines and spaces in php files...

When looking for extra lines and spaces in php files, what excactly are they talking about
I've the Rss feed addon and have to look for white spaces and lines in the begining and the end of files cause I get an error .

My question : what should I be looking for ?

This is reaaly a stupid question for most of you but I'm not familiar with php

27 Aug 2009, 2:57 AM
#2
afo avatar

afo

Totally Zenned

Join Date:
Aug 2004
Location:
New York City
Posts:
6,800
Plugin Contributions:
0

Re: When looking for extra lines and spaces in php files...

Blank lines and spaces at the beginning or end of a php file can cause all sorts of problems with the php processor. Your php files should begin with

<?php 

and end with

?>

There shouldn't be any blank lines or spaces before or after those.

Mary Ellen
I came; I saw; I Zenned
Taking over the world... one website at a time
Make sure brain is engaged before putting mouth in gear... or fingers to keyboard.

Holzheimer
Fan Odyssey

27 Aug 2009, 3:35 AM
#3
lieven23 avatar

lieven23

Zen Follower

Join Date:
Aug 2008
Posts:
340
Plugin Contributions:
0

Re: When looking for extra lines and spaces in php files...

I found a script that looks for these and it says I have a blank space at the end of this file:

//DEBUG: echo '<!-- I SEE cat: ' . $current_category_id . ' || vs cpath: ' . $cPath . ' || page: ' . $current_page . '

|| template: ' . $current_template . ' || main = ' . ($this_is_home_page ? 'YES' : 'NO') . ' -->';
?>

<?php echo rss_feed_link_alternate(); // RSS Feed ?> </head> <?php // NOTE: Blank line following is intended: ?>

Where is the error?

27 Aug 2009, 3:44 AM
#4
afo avatar

afo

Totally Zenned

Join Date:
Aug 2004
Location:
New York City
Posts:
6,800
Plugin Contributions:
0

Re: When looking for extra lines and spaces in php files...

It's impossible to tell this way. Open the file in question in a good text editor like Notepad++ or Crimson Editor (regular Notepad will do as well). Position your cursor after the closing ?> and delete any extra lines or spaces.

Mary Ellen
I came; I saw; I Zenned
Taking over the world... one website at a time
Make sure brain is engaged before putting mouth in gear... or fingers to keyboard.

Holzheimer
Fan Odyssey

27 Aug 2009, 1:26 PM
#5
lieven23 avatar

lieven23

Zen Follower

Join Date:
Aug 2008
Posts:
340
Plugin Contributions:
0

Re: When looking for extra lines and spaces in php files...

This is the end of my html_header.php file:

}

//DEBUG: echo '<!-- I SEE cat: ' . $current_category_id . ' || vs cpath: ' . $cPath . ' || page: ' . $current_page . ' || template: ' . $current_template . ' || main = ' . ($this_is_home_page ? 'YES' : 'NO') . ' -->';
?>

<?php echo rss_feed_link_alternate(); // RSS Feed ?> </head> <?php // NOTE: Blank line following is intended: ?>

Where to look?

28 Aug 2009, 5:32 AM
#6
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,294
Plugin Contributions:
39

Re: When looking for extra lines and spaces in php files...

lieven23:

This is the end of my html_header.php file:

}

//DEBUG: echo '<!-- I SEE cat: ' . $current_category_id . ' || vs cpath: ' . $cPath . ' || page: ' . $current_page . ' || template: ' . $current_template . ' || main = ' . ($this_is_home_page ? 'YES' : 'NO') . ' -->';
?>

<?php echo rss_feed_link_alternate(); // RSS Feed ?> </head> <?php // NOTE: Blank line following is intended: ?>

Where to look?

The file you have listed is intended to have a extra line (blank after it). Language files become "broken" when an additional linebreak or spaces follow the closing ?>

Like this

This is good

?>

This is not

?>[I]space[/I]
or [I]space[/I]

~Melanie

PRO-Webs, Inc. since 2003 https://pro-webs.net/

3 Sep 2009, 6:49 AM
#7
starcad avatar

starcad

New Zenner

Join Date:
Jul 2007
Posts:
53
Plugin Contributions:
0

Re: When looking for extra lines and spaces in php files...

Another method I use is to highlight the code. You can use 'Select All' or just press the left mouse key and scroll over the area. You will see the White space at the end of lines or at the bottom of the code as blank blue space.

this is a try.

Just left click over the above from the beginning to the end. The white space shows as blank blue.

Hope that makes sense.

9 Oct 2009, 1:20 PM
#8
blackwolf avatar

blackwolf

New Zenner

Join Date:
Sep 2009
Location:
Liverpool
Posts:
96
Plugin Contributions:
0

Re: When looking for extra lines and spaces in php files...

If I edit a file or install a new add-on, sometimes my website will just show blank pages so I have to go thru almost all files to look for these extra empty lines. I do it but it takes me an eternity. I have two questions.

  1. Why do these extra lines appear?
  2. Is there an easier way of finding these extra empty lines?
9 Oct 2009, 4:19 PM
#9
drbyte avatar

drbyte

Sensei

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

Re: When looking for extra lines and spaces in php files...

Article on finding problems causing blank pages: https://www.zen-cart.com/tutorials/index.php?article=82

.
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.