I am completely new to PHP and am doing online tutorials to learn. In this code:

<?php

$cars_on_lot = 10;

print "We have $cars_on_lot cars.\n
";

print "We got another new car.\n
";

$cars_on_lot++;

print "Now we have $cars_on_lot cars!\n<p>";

print '<b>$cars_on_lot++</b> is the same to PHP as <b>$cars_on_lot + 1.</b>';

?>

What does the "\n" mean?

This tutorial just all the sudden started using them without saying what the do-if anything...thanks!
Joel

'\n' is a newline.

It is called a carriage return.
You can check out google for the full description.
In a nutshell, it is the return/enter key.
For the script it seems useless. a <br /> would be more beneficial.

I use the \n when I build HTML in my PHP code and I want it to look clean when viewing the source insead of one large clump of code.

ie:

echo = '<p>some text</p>'."\n";
echo = '<p>some more text</p>'."\n";

Will output:

<p>some text</p>
<p>some more text</p>

Without the \n it would output

<p>some text</p><p>some more text</p>

You don't need to use it for HTML but it comes in handy when creating CVS files or text emails, to name a couple.

Hope this helps.

It is called a carriage return.

fyi: '\r' is the carriage return.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.