PHP code tags adding extra line on display

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gloomy
Forum Newbie
Posts: 5
Joined: Sun Jul 25, 2010 4:48 am

PHP code tags adding extra line on display

Post by Gloomy »

Hey im messing around with some php and noticed that when ever I use something like

Code: Select all

<?php
echo "hello";
?>
<font face="Arial" size="2">goodbye</font>
really simple, it adds a line between hello and goodbye when I run it in a browser, like

Code: Select all

hello

goodbye
Is there a way I could get the print out to remove the extra line so it appears like

Code: Select all

hello
goodbye
?

only used this as an example, the actual php im trying to work with only prints out if a IF condition is true but that works fine, no idea how to remove that extra space tho, any suggestions would be great thanks :)
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: PHP code tags adding extra line on display

Post by yacahuma »

Is this in a command line or in html output?
Gloomy
Forum Newbie
Posts: 5
Joined: Sun Jul 25, 2010 4:48 am

Re: PHP code tags adding extra line on display

Post by Gloomy »

Its a website, being viewed in a web browser, chrome to be specific, I wasent aware that you could use the code I gave above in my first post in terminal, maybe pieces of it, but as a whole... nope dont think so.

Would really love any help here, it seems like such a simple problem and cant seem to find any solutions, surely i not the first person to encounter this lol
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: PHP code tags adding extra line on display

Post by yacahuma »

The code you posted cannot include a br which is the only possible way you get a new line. The other way will be if you have a css like this
<style>
font {display:block}
</style>
Gloomy
Forum Newbie
Posts: 5
Joined: Sun Jul 25, 2010 4:48 am

Re: PHP code tags adding extra line on display

Post by Gloomy »

hmm thanks, i just tried it out without all my other code, it prints out exactly as it should, didnt think to check it.

Theres something with my other code that is messing with it lol, damnit, was hoping for something simple :P
Gloomy
Forum Newbie
Posts: 5
Joined: Sun Jul 25, 2010 4:48 am

Re: PHP code tags adding extra line on display

Post by Gloomy »

woot! found the problem!, havent solved it, im up happy i found it lol, its the <form> tag. can someone please explain why there is a <br> between the form and the php code :)

Code: Select all

<?php
	echo "inside php";
?>
<form>
inside form
</form>
I thought it should print out like

Code: Select all

inside phpinside form
or maybe

Code: Select all

inside php
inside form
except it prints out like...

Code: Select all

inside php

inside form
but it only does it for the <form> tag, any ideas?
Gloomy
Forum Newbie
Posts: 5
Joined: Sun Jul 25, 2010 4:48 am

Re: PHP code tags adding extra line on display

Post by Gloomy »

incase anyone else has this annoying little problem, simple as it is it took me agggggessssssss to find a solution, here it is.

Code: Select all

<STYLE type="text/css">
form{display:inline;} 
</STYLE>

<?php
hello
?>

<form action="--WEBBOT-SELF--" method="POST">inside form
</form>
:)
Post Reply