idire Posted November 18, 2008 Share Posted November 18, 2008 I'm trying to make php output nicely formatted html code so tried: <?php echo $data.'\n'; ?> which doesnt work. also tried: <?php echo $data.'\r\n'; ?> also this does nothing: <?php echo 'Username: \n '.$row->username."\r\n"; ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted November 18, 2008 Share Posted November 18, 2008 Did you try <BR /> ? Quote Link to comment Share on other sites More sharing options...
idire Posted November 18, 2008 Author Share Posted November 18, 2008 <br/> works but thats not what i'm trying to do. I'm trying to make the outputted html appear on a new line, instead of going on forever so <table><tr><td></td></tr></table> goes to: <table> <tr> <td> </td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
gmcalp Posted November 18, 2008 Share Posted November 18, 2008 echo "<h3>".$data."</h3>\n"; Quote Link to comment Share on other sites More sharing options...
idire Posted November 18, 2008 Author Share Posted November 18, 2008 echo "<h3>test</h3> test"; gives the same output as: echo "<h3>test</h3> \n test"; h3 has a new paragraph started after it anyway, so that tells me nothing? Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted November 18, 2008 Share Posted November 18, 2008 OK then, try: echo "<table>\n<tr>\n<td>\n</td>\n</tr>\n</table>\n"; But I think you'll find the original example worked perfectly Quote Link to comment Share on other sites More sharing options...
DarkerAngel Posted November 18, 2008 Share Posted November 18, 2008 [removed post] Quote Link to comment Share on other sites More sharing options...
trq Posted November 18, 2008 Share Posted November 18, 2008 \n works as expected when between double quotes. Quote Link to comment Share on other sites More sharing options...
idire Posted November 18, 2008 Author Share Posted November 18, 2008 Adding ."\n"; onto the end of the echoes seems to work. Never knew there was a difference between single and double quotes. Stupid me. Thanks all. Quote Link to comment Share on other sites More sharing options...
gmcalp Posted November 18, 2008 Share Posted November 18, 2008 from your first example, this should work: <?php echo "Username: ".$whateverdatayouwant."\n"; ?> Quote Link to comment Share on other sites More sharing options...
trq Posted November 18, 2008 Share Posted November 18, 2008 Never knew there was a difference between single and double quotes. Variables and escape sequences are interpolated within double quotes only. Quote Link to comment Share on other sites More sharing options...
idire Posted November 18, 2008 Author Share Posted November 18, 2008 Ah so use double quotes when you want the server to look inside the quotes for variables and \n \t etc. Thanks Quote Link to comment 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.