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 trial

PHP

Marco Otto
Marco Otto
5,342 Points

bRaKinG MADE: No line break "\n" :-(

Why does'nt the Preview of the workspace show line breaks?

<?php $name = $_POST["name"]; $email = $_POST["email"]; $details = $_POST["details"];

echo "Name " . $name . "\n"; echo "E-Mail " . $email . "\n"; echo "Details " . $details . "\n"; ?>

2 Answers

Hey Marco I believe you forgot to echo the <pre> tag before and </pre> closing tag after you echo your variables. Good luck!

Sorry, I typed that wrong, you're supposed to echo an html tag called pre before and after you echo your variables

Marco Otto
Marco Otto
5,342 Points

Hi Kane,

ok thanks! Did not know that \n only works within the HTML-tag pre like this:

<?php
$one = "1";
$two = "2";

echo "<pre>";
echo "foo:" .$one. "\n";
echo "boo:" .$two. "\n";
echo "</pre>";
?>  

If I dont wanna use the tag: <pre> I use </br> instead:

<?php
$one = "1";
$two = "2";

echo "foo:" .$one. "</br>";
echo "boo:" .$two. "</br>";
?>

Now I got it! :-)