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

Erik L
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Erik L
Full Stack JavaScript Techdegree Graduate 19,470 Points

Is the output in my terminal displaying correctly

so I am learning about php and I have this in my text editor:

<?php
$num_one = 1;
$num_two = 2;
$num_three = 3;

echo $num_three

?>

when I run my code on my comuter I get this output

3RSG-5000_eramirez:PHP Basics erikramirez$

the 3 is right next to the other output, I was wondering if this is correct since I usually see the output right after the first line

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi, @Erik L! That is entirely correct. I know it seems odd given your JavaScript background, but unless you tell PHP to print a new line, it won't.

So where you have:

echo $num_three; // there should be a semicolon there

Try:

echo $num_three . "\n";

Additionally, make sure you always include semicolons at the end of your statements. PHP is not at all forgiving about missing semicolons like JavaScript is :smiley:

Hope this helps! :sparkles:

additional information

The automatic addition (or lack of it) of a new line may also depend on your OS. Windows automatically inserts a new line, but I believe that to be the default behavior of the console and not PHP.