Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Missing echo new lines 1

Status
Not open for further replies.

gnubie

Programmer
Apr 16, 2002
103
US
Code:
<?php
/*
Windows XP-SP3, PHP 5, Firefox 3
Expected:
Line 1
Line 2

Got:
Line 1 Line 2

Why are newlines missing?
*/
echo "Line 1\n";
echo "Line 2\n";
?>
 
Hi

That depends on the possibly other scripts which call this and your web server's configuration.

But most probably because you not read the HTML specification.

You could :
PHP:
[teal]<?php[/teal]
[gray]/*[/gray]
[gray]Deliver the content as text/plain[/gray]
[gray]*/[/gray]
[COLOR=darkgoldenrod]header[/color][teal]([/teal][green][i]'Content-type: text/plain'[/i][/green][teal]);[/teal]
[b]echo[/b] [green][i]"Line 1\n"[/i][/green][teal];[/teal]
[b]echo[/b] [green][i]"Line 2\n"[/i][/green][teal];[/teal]
[teal]?>[/teal]
Or :
PHP:
[teal]<?php[/teal]
[gray]/*[/gray]
[gray]Format the content as text/html[/gray]
[gray]*/[/gray]
[b]echo[/b] [green][i]"Line 1<br>\n"[/i][/green][teal];[/teal]
[b]echo[/b] [green][i]"Line 2<br>\n"[/i][/green][teal];[/teal]
[teal]?>[/teal]

Feherke.
 
Feherke:

Thanks. That was exactly the problem.

GN
 
I know it's off topic, but how do you colour code your "code" posts on this forum like you have done?

Can't see it in the help anywhere...

Regards,

Martin

Computing Design And Services:
 
Hi

MJB3K, I suppose that question was for me.

I use an external tool, the GNU [tt]source-highlight[/tt], with TGML outlang.

Other members have other solutions, like customizing the [tt]Text::Highlight[/tt] [tt]perl[/tt] module or converting [tt]vim[/tt]'s output.

So far there is no syntax highlighting solution provided by the forum engine.

Feherke.
 
OK thanks =] they should incorperate that script into this forum as it would make code reading much more readable and clear!

Regards,

Martin

Computing Design And Services:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top