Jump to content

the most newbie question ever, regarding \n


quartney

Recommended Posts

Hi, I am trying to learn php from a book and am doing the sample exercises.  I can't figure out why \n isn't making a new line for me.  I am using php 5.2.0.  Here is the code, and it is being output on one line.

 

<?php

$name = "Paul";

print "Your name is $name\n";

$name2 = $name;

$age = 20;

print "Your name is $name2, and your age is $age\n";

print "Goodbye, $name!\n";

?>

 

thanks a lot for your help!

Q.

If you're displaying the output in a browser window then the "\n" has no meaning to the browser and it changes it to a space. To display a newline in a browser window you need to use the "<br>" tag. If you do a "show source" you will see the newlines.

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.