Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKartikey Shahi
Courses Plus Student 2,002 Pointswhy i m not getting line breaks after first string ?
<?php $user_name = "ABC \n"; $user_pro = "Frontend Web Developer"; echo $user_name; echo $user_pro; ?>
4 Answers
Kai Nightmode
37,045 PointsIf the output display is a web page you would need to wrap the output in PRE tags to enable regular line breaks. For example...
<pre>
ABC\n
Frontend Web Developer
</pre>
Otherwise it may be easier to use a BR tag instead of a newline indicator. For example...
ABC<br>
Frontend Web Developer
Cheers!
Kartikey Shahi
Courses Plus Student 2,002 Pointspre ?
Kai Nightmode
37,045 PointsAh right! PRE is an HTML element for containing pre-formatted text. This means text inside a PRE element will retain spaces, tabs, and line breaks. This is very different than most HTML elements which ignore things like more than one sequential space.
The Mozilla Developer Network has more details on the PRE element if you are interested. There is also a good explanation of the PRE element at SitePoint.
Kartikey Shahi
Courses Plus Student 2,002 Pointsthanx
Murat Hasdemir
Front End Web Development Techdegree Graduate 20,968 Points\n is for computers and br for humans. don't forget web site is for humans not for computers and outputs like json for computers.
Kartikey Shahi
Courses Plus Student 2,002 PointsKartikey Shahi
Courses Plus Student 2,002 Pointsthanx but what pre is ?
Kai Nightmode
37,045 PointsKai Nightmode
37,045 PointsI'm not sure what you mean. Can you rephrase "...what is ?"