<?php
printf("This is the first line. \n");
printf("This is the second line");
?>

This is the code but it isnt printing in new line.

What you need to do is use the <br> HTML tag before each newline character. HTML doesn't accept newlines.
So, for example :

CODE
echo "this should be <br><br> a new line here <br> and here, too";

You won't need to do the carriage return for a new line in the page.

you can make carriage returns work. HOWEVER you have to use I beileve is the pre tag. And that is kinda of messy at times. You're better off using a br tag.

just keeping options open.

tanks

Member Avatar for bearcatFulton

%0A

this should be like this
printf("this is first line /n this is second line ")

Hi... friends.. I have a problem with displaying popup message box. I would like to display a popup box including php values. For example my view is..

echo "<script>alert('...some text...'+'php value'+'..some text...')</script>";

I think you understand my problem. i tried alot but i didn't get. So, plz. help me in this one... thank you...

Please do not hijack old threads. But as as answer to your problem, do not use + use '.' (dot). For example,

echo "<script>alert('text".$varName."')</script>" 
//OR
echo "<script>alert('text {$varName} ')</script>"

If you have further doubts please start a new thread.

<?php
echo "This is First Line";
?>
<br>
<?php
echo "This is second line";
?>

<?php
echo "This is First line " , "<br>" , "This is second line ";
?>

this one try

<?php
echo "This is first line" , "<br>" , "This is second line";
?>

<?php
echo "<div>\n";
echo "line one \n line two \n";
echo "</div>";
?>

the output would be

line one line two

but if you check the source, it would be

<div>
line one line two
</div>

if you want to output a newline in your html, you will have to use <br /> in your php code:

<?php
echo "<div>\n";
echo "line one <br /> line two \n";
echo "</div>";
?>

the output would be:

line one
line two

and the source would be

<div>
line one
line two
</div>

You can also use this:

<?php
echo "This is first line<br>This is second line";
?>

If I use double quotes I get the desired results, but not when using single quotes

    Ex. 
       $s = '<Div id="myID">\n';     //doesn't work
       $s = '<Div id="myID">'."\n";  //does work   

<br>
break...
"space"

\n will show effect in cmd only.To enter a new line in web you should use <br> or </br> tag. however in source it will show a new line but html parser does'nt enters a new line without <br> tag

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.