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 trialJusto Montoya
3,799 Points\n indents the first "echo $greeting;" line.
In the video, adding \n at the end of the $greeting string did not indent the "Hello, Friends!" line, but on mine it does. Am I doing anything wrong? I am using google chrome browser.
<?php
$greeting = "Hello, Friends!\n";
$greeting{0} = "J";
$secondary_greeting = "How are you today?";
echo $greeting;
echo $secondary_greeting;
?>
3 Answers
David Weigel
8,265 PointsTo clarify a bit of what Redmar is saying:
I was able to get the two sentences to line up correctly as shown by doing the following:
after the pre opening tag, have the php opening tag immediately follow. This would look like:
<pre><?php
followed by any whitespace you want for readability.
Redmar de Haan
11,280 Points<pre><?php should be on the same line (and no space).
The <pre> tag defines preformatted text. Text in a <pre> element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks.
Ted Sumner
Courses Plus Student 17,967 PointsI have never really used \n, but try adding a space between the ! and \n. I use the html break tag.
Ted Sumner
Courses Plus Student 17,967 PointsTed Sumner
Courses Plus Student 17,967 PointsYes, that would make a difference.