DallasNYC Posted March 8, 2006 Share Posted March 8, 2006 Hi, I spend alot of my time over at flashkit.com dealing mostly with flash. But I was recently involved with a thread dealing with PHP adding unwanted white space to a string. It turns out that if an extra line is left after the PHP closing tag, a space could get added to the string...[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]In php, if you are using an editor that has line numbers you may have something like this:66 echo 'response=passed';67 ?>68You would need to remove line 68. PHP sees that as output. Your script should end as this:66 echo 'response=passed';67 ?>And no extra line.I can replicate this issue and solve this issue just by changine the above code around.[/quote][a href=\"http://flashkit.com/board/showthread.php?t=675912\" target=\"_blank\"]http://flashkit.com/board/showthread.php?t=675912[/a]Ive only done a little PHP coding, but this interest me because I never read anything about this.I'm curious if someone can enlighten me more about this issue? Is there more documentation/articles about what other things could result in whitespace being added to a string? (I did a search for 'white space' etc, but came up with too many results)Recently there is a new thread with another person having problems with added whitespace to thier strings..[a href=\"http://flashkit.com/board/showthread.php?t=676326&page=2&pp=20\" target=\"_blank\"]http://flashkit.com/board/showthread.php?t...26&page=2&pp=20[/a]I notice that in this particular issue, the author follows the echo tag with a "//" remark tag, but was not certain if that would cause the same white space issue?Thanks so much,Dallas Quote Link to comment https://forums.phpfreaks.com/topic/4392-help-with-php-adding-white-space-to-a-string/ Share on other sites More sharing options...
solarisuser Posted March 8, 2006 Share Posted March 8, 2006 [code]$var = trim($var);[/code][!--quoteo(post=352697:date=Mar 7 2006, 04:53 PM:name=DallasNYC)--][div class=\'quotetop\']QUOTE(DallasNYC @ Mar 7 2006, 04:53 PM) [snapback]352697[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi, I spend alot of my time over at flashkit.com dealing mostly with flash. But I was recently involved with a thread dealing with PHP adding unwanted white space to a string. It turns out that if an extra line is left after the PHP closing tag, a space could get added to the string...[a href=\"http://flashkit.com/board/showthread.php?t=675912\" target=\"_blank\"]http://flashkit.com/board/showthread.php?t=675912[/a]Ive only done a little PHP coding, but this interest me because I never read anything about this.I'm curious if someone can enlighten me more about this issue? Is there more documentation/articles about what other things could result in whitespace being added to a string? (I did a search for 'white space' etc, but came up with too many results)Recently there is a new thread with another person having problems with added whitespace to thier strings..[a href=\"http://flashkit.com/board/showthread.php?t=676326&page=2&pp=20\" target=\"_blank\"]http://flashkit.com/board/showthread.php?t...26&page=2&pp=20[/a]I notice that in this particular issue, the author follows the echo tag with a "//" remark tag, but was not certain if that would cause the same white space issue?Thanks so much,Dallas[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/4392-help-with-php-adding-white-space-to-a-string/#findComment-15243 Share on other sites More sharing options...
DallasNYC Posted March 8, 2006 Author Share Posted March 8, 2006 Thanks solaris, I am aware of trim() and other ways to remove the whitespace. I'm trying to learn ways to prevent it from happening in the first place.I'm curious if someone can enlighten me more about this issue? Is there more documentation/articles about what other things could result in whitespace being added to a string? Quote Link to comment https://forums.phpfreaks.com/topic/4392-help-with-php-adding-white-space-to-a-string/#findComment-15245 Share on other sites More sharing options...
greycap Posted March 8, 2006 Share Posted March 8, 2006 [!--quoteo(post=352702:date=Mar 7 2006, 07:14 PM:name=DallasNYC)--][div class=\'quotetop\']QUOTE(DallasNYC @ Mar 7 2006, 07:14 PM) [snapback]352702[/snapback][/div][div class=\'quotemain\'][!--quotec--]Thanks solaris, I am aware of trim() and other ways to remove the whitespace. I'm trying to learn ways to prevent it from happening in the first place.I'm curious if someone can enlighten me more about this issue? Is there more documentation/articles about what other things could result in whitespace being added to a string?[/quote]From what I can tell, you are loading a .php file into a flash animation.Within the <? ?> tags, thats all interpreted by PHP. Everything else is interpreted as html. That extra line is output by your webserver, not by php.This isnt a bug, just an apparent misunderstanding. Quote Link to comment https://forums.phpfreaks.com/topic/4392-help-with-php-adding-white-space-to-a-string/#findComment-15257 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.