Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #3262 > unrolled thread
| Started by | Linus Flustillbe <admin@nacs.dyndns-office.com> |
|---|---|
| First post | 2011-10-02 14:00 +0000 |
| Last post | 2011-10-04 09:38 -0400 |
| Articles | 8 on this page of 28 — 13 participants |
Back to article view | Back to comp.lang.php
Question about new lines Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-02 14:00 +0000
Re: Question about new lines "Jeff Gaines" <jgaines_newsid@yahoo.co.uk> - 2011-10-02 14:17 +0000
Re: Question about new lines Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-02 16:36 +0000
Re: Question about new lines "Jeff Gaines" <jgaines_newsid@yahoo.co.uk> - 2011-10-02 21:58 +0000
Re: Question about new lines The Natural Philosopher <tnp@invalid.invalid> - 2011-10-03 05:35 +0100
Re: Question about new lines "Jeff Gaines" <jgaines_newsid@yahoo.co.uk> - 2011-10-03 07:53 +0000
Re: Question about new lines Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-03 11:40 +0200
Re: Question about new lines Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-03 07:26 -0400
Re: Question about new lines "Jeff Gaines" <jgaines_newsid@yahoo.co.uk> - 2011-10-03 11:42 +0000
Re: Question about new lines Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-03 08:48 -0400
Re: Question about new lines "Jeff Gaines" <jgaines_newsid@yahoo.co.uk> - 2011-10-03 13:05 +0000
Re: Question about new lines Robert Heller <heller@deepsoft.com> - 2011-10-03 08:49 -0500
Re: Question about new lines "Jeff Gaines" <jgaines_newsid@yahoo.co.uk> - 2011-10-03 14:11 +0000
Re: Question about new lines Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-03 10:57 -0400
Re: Question about new lines "Jeff Gaines" <jgaines_newsid@yahoo.co.uk> - 2011-10-03 15:14 +0000
Re: Question about new lines Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-03 14:57 -0400
Re: Question about new lines Mason Barge <masonbarge@gmail.com> - 2011-10-05 15:20 -0400
Re: Question about new lines Tim Streater <timstreater@greenbee.net> - 2011-10-06 12:27 +0100
Re: Question about new lines Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-03 10:54 -0400
Re: Question about new lines Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-10-03 14:51 +0200
Re: Question about new lines Tim Streater <timstreater@greenbee.net> - 2011-10-06 12:21 +0100
Re: Question about new lines The Natural Philosopher <tnp@invalid.invalid> - 2011-10-02 16:21 +0100
Re: Question about new lines Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-02 11:43 -0400
Re: Question about new lines Denis McMahon <denismfmcmahon@gmail.com> - 2011-10-02 19:08 +0000
Re: Question about new lines "Peter H. Coffin" <hellsop@ninehells.com> - 2011-10-02 19:57 -0500
Re: Question about new lines Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2011-10-02 23:52 +0200
Re: Question about new lines Gordon Burditt <gordon@hammy.burditt.org> - 2011-10-03 00:15 -0500
Re: Question about new lines Michael Joel <no@please.com> - 2011-10-04 09:38 -0400
Page 2 of 2 — ← Prev page 1 [2]
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Date | 2011-10-06 12:21 +0100 |
| Message-ID | <timstreater-128560.12215206102011@news.individual.net> |
| In reply to | #3274 |
In article <j6be24$k8h$4@news.albasani.net>, The Natural Philosopher <tnp@invalid.invalid> wrote: > Jeff Gaines wrote: > > On 02/10/2011 in message <4e889326$0$5371$9a566e8b@news.aliant.net> > > Linus Flustillbe wrote: > > > >> or we could use a <p> to force a paragraph switch. > >> Thanks all for your help, I have it working now. > > > > Don't forget you should close a <p> tag with </p> > > > I have never seen that ever in any source Then you've only been looking at rubbish source. -- Tim "That excessive bail ought not to be required, nor excessive fines imposed, nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
[toc] | [prev] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2011-10-02 16:21 +0100 |
| Message-ID | <j69vhh$9ji$3@news.albasani.net> |
| In reply to | #3262 |
Linus Flustillbe wrote:
> I come from a scripting background so am not unfamiliar
> with the concept of CR/LF characters. I am in the process
> of learning PHP via the following tutorial
>
> http://mobilitystudies.com/mob/images/stories/PHP_Tutorial_From_beginner_to_master.pdf
>
> Currently I have "hello.php" with the following lines of code
>
> -------------------------
> <html>
> <body>
> <?php
> $d=date("D");
> if ($d=="Fri")
> echo "Have a nice weekend!";
> elseif ($d=="Sun")
> echo "Have a nice Sunday!";
> else echo "Have a nice day!";
> echo "\nhello boss"."\t"."does this work".PHP_EOL;
> echo "again";
> ?>
> </body>
> </html>
> ---------------------------------
> When I load this in my browser I see the following
> ------------------------
> Have a nice Sunday! hello boss does this work again
> -------------------------
> And if I look at the page source (using Firefox)
> --------------------------
> <html>
> <body>
> Have a nice Sunday!
> hello boss does this work
> again</body>
> </html>
> ------------------------
> Should the "\n" not push a NewLine out to the output?
> I did some research and found that the PHP_EOL seems to be what is
> recommended since it is platform independant. But it doesn't work
> either.
>
> Can anyone suggest or point out what I am doing wrong, or is this a flaw
> in php?
>
No, its a flaw in your understanding of HTML which does not recognise
white space including new lines.
use <BR> instead.
> Thanks
>
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2011-10-02 11:43 -0400 |
| Message-ID | <j6a0ra$93e$1@dont-email.me> |
| In reply to | #3262 |
On 10/2/2011 10:00 AM, Linus Flustillbe wrote:
> I come from a scripting background so am not unfamiliar
> with the concept of CR/LF characters. I am in the process
> of learning PHP via the following tutorial
>
> http://mobilitystudies.com/mob/images/stories/PHP_Tutorial_From_beginner_to_master.pdf
>
> Currently I have "hello.php" with the following lines of code
>
> -------------------------
> <html>
> <body>
> <?php
> $d=date("D");
> if ($d=="Fri")
> echo "Have a nice weekend!";
> elseif ($d=="Sun")
> echo "Have a nice Sunday!";
> else echo "Have a nice day!";
> echo "\nhello boss"."\t"."does this work".PHP_EOL;
> echo "again";
> ?>
> </body>
> </html>
> ---------------------------------
> When I load this in my browser I see the following
> ------------------------
> Have a nice Sunday! hello boss does this work again
> -------------------------
> And if I look at the page source (using Firefox)
> --------------------------
> <html>
> <body>
> Have a nice Sunday!
> hello boss does this work
> again</body>
> </html>
> ------------------------
> Should the "\n" not push a NewLine out to the output?
> I did some research and found that the PHP_EOL seems to be what is
> recommended since it is platform independant. But it doesn't work
> either.
>
> Can anyone suggest or point out what I am doing wrong, or is this a flaw
> in php?
>
> Thanks
>
The fact that it looks OK in your page source indicates this isn't a PHP
problem, but an HTML one. HTML ignores most whitespace.
Before getting into PHP too much, I would suggest you get a book on HTML
and learn more about how it works, or you'll continue to fight
"problems" like this in the future.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2011-10-02 19:08 +0000 |
| Message-ID | <4e88b6a8$0$31137$a8266bb1@newsreader.readnews.com> |
| In reply to | #3262 |
On Sun, 02 Oct 2011 14:00:27 +0000, Linus Flustillbe wrote: > I come from a scripting background so am not unfamiliar with the concept > of CR/LF characters. I am in the process of learning PHP via the > following tutorial A web browser considers new lines within the text content of html documents to be white space, just as it considers spaces and tabs within the text content of html documents to be white space. Line breaks are signalled by "<br>" or "<br />" (which you use depends on the dtd you declare, if you don't declare a dtd use <br>) and paragraphs are wrapped in "<p></p>". In html, these elements control forced line breaks. Carriage returns in the text content of html documents don't generate line breaks. If you're using a scripting language such as php to generate presentational markup such as html, you need to make sure you understand what correct presentational markup looks like first. Rgds Denis McMahon
[toc] | [prev] | [next] | [standalone]
| From | "Peter H. Coffin" <hellsop@ninehells.com> |
|---|---|
| Date | 2011-10-02 19:57 -0500 |
| Message-ID | <slrnj8i24n.hbg.hellsop@nibelheim.ninehells.com> |
| In reply to | #3269 |
On 02 Oct 2011 19:08:26 GMT, Denis McMahon wrote: > Line breaks are signalled by "<br>" or "<br />" (which you use depends on > the dtd you declare, if you don't declare a dtd use <br>) and paragraphs > are wrapped in "<p></p>". In html, these elements control forced line > breaks. Well, to be REALLY pedantic, the <p> marker doesn't force a line break. It does whatever the paragraph break is supposed to do, whether that's vertical boundry space, boundry with indent, indent alone, outdent, continuous with pilcrow, etc. It's all dependant on what the browser is set up to support, what styles are in effect, whether they're from the site or overridden by the user, etc. HTML is not layout. -- 59. I will never build a sentient computer smarter than I am. --Peter Anspach's list of things to do as an Evil Overlord
[toc] | [prev] | [next] | [standalone]
| From | Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> |
|---|---|
| Date | 2011-10-02 23:52 +0200 |
| Message-ID | <j6amfk$3b1$1@news.albasani.net> |
| In reply to | #3262 |
Linus Flustillbe schrieb:
> -------------------------
> <html>
> <body>
> <?php
> $d=date("D");
> if ($d=="Fri")
> echo "Have a nice weekend!";
> elseif ($d=="Sun")
> echo "Have a nice Sunday!";
> else echo "Have a nice day!";
> echo "\nhello boss"."\t"."does this work".PHP_EOL;
> echo "again";
> ?>
> </body>
> </html>
> ---------------------------------
> When I load this in my browser I see the following
> ------------------------
> Have a nice Sunday! hello boss does this work again
As was to be expected on a Sunday.
> -------------------------
> And if I look at the page source (using Firefox)
> --------------------------
> <html>
> <body>
> Have a nice Sunday!
> hello boss does this work
> again</body>
> </html>
> ------------------------
As was to be expected on a Sunday.
> Should the "\n" not push a NewLine out to the output?
Well it does, doesn't it? Without the "\n" and the PHP_EOL your source
would look like this:
> Have a nice Sunday!hello boss does this workagain
The output of PHP is the HTML source code. How the browser renders that
is another matter. If you want the line breaks to appear in the
browser's output, do as the other posts suggest.
Greetings,
Thomas
--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
[toc] | [prev] | [next] | [standalone]
| From | Gordon Burditt <gordon@hammy.burditt.org> |
|---|---|
| Date | 2011-10-03 00:15 -0500 |
| Message-ID | <-PSdnTbKg8112RTTnZ2dnUVZ_gKdnZ2d@posted.internetamerica> |
| In reply to | #3262 |
> I come from a scripting background so am not unfamiliar
> with the concept of CR/LF characters. I am in the process
> of learning PHP via the following tutorial
A newline in output interpreted as HTML is rendered no differently
from a space or series of spaces. It shows up as a newline in "view
source" of browsers but not in rendered HTML.
If you want to cause a line break, do it in HTML. <br> and <p> are
commonly used for this. Also, there's <tr> inside tables, which
does a bit more than just a line break.
If you output your text with header("Content-Type: text/plain")
(read the documentation about how to use this: HTTP headers have
to come *before* any text sent to the browser. Even a single space
or newline.) or otherwise get the web server to call it a plain
text file rather than HTML, newlines will be visible.
[toc] | [prev] | [next] | [standalone]
| From | Michael Joel <no@please.com> |
|---|---|
| Date | 2011-10-04 09:38 -0400 |
| Message-ID | <3n2m87po6jihb93lem9k63cq2rtpro2bl1@4ax.com> |
| In reply to | #3262 |
On 02 Oct 2011 14:00:27 GMT, Linus Flustillbe <admin@nacs.dyndns-office.com> wrote: >I come from a scripting background so am not unfamiliar >with the concept of CR/LF characters. I am in the process >of learning PHP via the following tutorial > [SNIP] >Can anyone suggest or point out what I am doing wrong, or is this a flaw >in php? > >Thanks Simple Answer: \n is PHP for breaking a line. It is not translated as the HTML <BR> as you (and I when I first started using PHP) had been expecting. It will format your HTML source with new lines - without it all the source would run together on one line. To have the browser break a line you need to still each to the browser an HTML line break <BR>. So examples: code: echo "1, 2, 3, 4, \n5, 6, 7"; output: 1, 2, 3, 4, 5, 6, 7 source view: 1, 2, 3, 4, 5, 6, 7 -------------------------------------------- code: echo "1, 2, 3, 4, \n<BR>5, 6, 7"; output: 1, 2, 3, 4, 5, 6, 7 source view: 1, 2, 3, 4, <BR>5, 6, 7 -------------------------------------------- code: echo "1, 2, 3, 4, \n<BR>\n5, 6, 7"; output: 1, 2, 3, 4, 5, 6, 7 source view: 1, 2, 3, 4, <BR> 5, 6, 7 Hope that makes it simple and clear. Mike
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.php
csiph-web