Connecting Tech Pros Worldwide Forums | Help | Site Map

Newline "\n" does not work...

Gregory
Guest
 
Posts: n/a
#1: Jul 17 '05
I am working through the exercises in the book "Learning PHP 5". I am
using OS 10.3.7, with Apache, Safari and IE. When I execute the
following code, the newline "\n" does not work. The ouput is all on
one line in both browsers. I read through the PHP website to no avail.
What is wrong?
[color=blue]
>From example 2-17: Operating on Variables[/color]
<?php
$price = 23.95;
$tax_rate = 0.08;
$tax_amount = $price * $tax_rate;
$total_cost = $price + $tax_amount;
$username = 'james';
$domain = '@example.com';
$email_address = $username . $domain;

print 'The tax is ' .$tax_amount;
print "\n";
print 'The total cost is ' .$total_cost;
print "\n";
print $email_address;
?>


Chris Hope
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Newline "\n" does not work...


Gregory wrote:
[color=blue]
> I am working through the exercises in the book "Learning PHP 5". I am
> using OS 10.3.7, with Apache, Safari and IE. When I execute the
> following code, the newline "\n" does not work. The ouput is all on
> one line in both browsers. I read through the PHP website to no
> avail.
> What is wrong?
>[color=green]
>>From example 2-17: Operating on Variables[/color]
> <?php
> $price = 23.95;
> $tax_rate = 0.08;
> $tax_amount = $price * $tax_rate;
> $total_cost = $price + $tax_amount;
> $username = 'james';
> $domain = '@example.com';
> $email_address = $username . $domain;
>
> print 'The tax is ' .$tax_amount;
> print "\n";
> print 'The total cost is ' .$total_cost;
> print "\n";
> print $email_address;
> ?>[/color]

Refer to this thread from less than a month ago:

http://www.google.co.nz/groups?hl=en...3D20%26hl%3Den

TinyURL version of the above:

http://tinyurl.com/5w9gh

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Tom Thackrey
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Newline "\n" does not work...



On 2-Apr-2005, "Gregory" <itisgregory@yahoo.com> wrote:
[color=blue]
> I am working through the exercises in the book "Learning PHP 5". I am
> using OS 10.3.7, with Apache, Safari and IE. When I execute the
> following code, the newline "\n" does not work. The ouput is all on
> one line in both browsers. I read through the PHP website to no avail.
> What is wrong?
>[color=green]
> >From example 2-17: Operating on Variables[/color]
> <?php
> $price = 23.95;
> $tax_rate = 0.08;
> $tax_amount = $price * $tax_rate;
> $total_cost = $price + $tax_amount;
> $username = 'james';
> $domain = '@example.com';
> $email_address = $username . $domain;
>
> print 'The tax is ' .$tax_amount;
> print "\n";
> print 'The total cost is ' .$total_cost;
> print "\n";
> print $email_address;
> ?>[/color]

Remember browsers expect HTML. HYML interprets newline as white space. To
get a newline in HTML use

print "<br>";



--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to jamesbutler@willglen.net (it's reserved for spammers)
Gregory
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Newline "\n" does not work...


Thanks for the valuable link! I am glad to see that I was not the only
one who asked this question.

Gregory
Guest
 
Posts: n/a
#5: Jul 17 '05

re: Newline "\n" does not work...


I will do that...now I understand what is going on...Chris Hope posted
this link that helped...
http://www.google.co.nz/groups ?hl=en&lr=&ie=UTF-8&threadm=11
2s8akhdek...

JDS
Guest
 
Posts: n/a
#6: Jul 17 '05

re: Newline "\n" does not work...


On Sat, 02 Apr 2005 20:31:13 -0800, Gregory wrote:
[color=blue]
> Thanks for the valuable link! I am glad to see that I was not the only
> one who asked this question.[/color]

And you seldom will be. Google a bit before asking. (And no, I'm not
being rude, mean, or an asshole by saying this, or in this tone).

--
JDS | jeffrey@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

Closed Thread