Jump to content


Photo

Linebreaks in PHP?


  • Please log in to reply
4 replies to this topic

#1 Fira

Fira
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 25 September 2006 - 03:04 AM

Simple question - how can I end a block of text with a linebreak?

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 25 September 2006 - 03:16 AM

echo "this is a block of text\n";


#3 Fira

Fira
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 25 September 2006 - 03:21 AM

<?php

echo "text1\n";
echo "text2\n";

?>


This code results in

text1 text2


Is it supposed to?

#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 25 September 2006 - 03:42 AM

If you view it in a browser it will. View the source however and you will see the linebeaks. If its html linebreaks you want, well.... that has nothing to do with php really.

<?php

echo "text1<br />";
echo "text2<br />";

?>


#5 Fira

Fira
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 25 September 2006 - 04:11 AM

Yes, that's what I needed. Thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users