FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Question about new lines
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Question about new lines [message #175489] Sun, 02 October 2011 14:00 Go to next message
Linus Flustillbe is currently offline  Linus Flustillbe
Messages: 2
Registered: October 2011
Karma: 0
Junior Member
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

--
*************************************************************************** *****
* Usenet Impovement Project http://nacs.dyndns-office.com/usenet
* Bakers trade bread recipes on a knead-to-know basis.
*************************************************************************** ******
Re: Question about new lines [message #175490 is a reply to message #175489] Sun, 02 October 2011 14:17 Go to previous messageGo to next message
Jeff Gaines is currently offline  Jeff Gaines
Messages: 11
Registered: October 2011
Karma: 0
Junior Member
On 02/10/2011 in message <4e886e7b$0$5356$9a566e8b(at)news(dot)aliant(dot)net> Linus
Flustillbe wrote:

> 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.

I would use:

echo "<br />";

Which will force a line break in HTML.

--
Jeff Gaines Wiltshire UK
I take full responsibility for what happened - that is why the person that
was responsible went immediately.
(Gordon Brown, April 2009)
Re: Question about new lines [message #175491 is a reply to message #175489] Sun, 02 October 2011 15:21 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
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
>
Re: Question about new lines [message #175492 is a reply to message #175489] Sun, 02 October 2011 15:43 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
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(at)attglobal(dot)net
==================
Re: Question about new lines [message #175494 is a reply to message #175490] Sun, 02 October 2011 16:36 Go to previous messageGo to next message
Linus Flustillbe is currently offline  Linus Flustillbe
Messages: 2
Registered: October 2011
Karma: 0
Junior Member
On 2011-10-02, Jeff Gaines <jgaines_newsid(at)yahoo(dot)co(dot)uk> wrote:
> On 02/10/2011 in message <4e886e7b$0$5356$9a566e8b(at)news(dot)aliant(dot)net> Linus
> Flustillbe wrote:
>
>> 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.
>
> I would use:
>
> echo "<br />";
>
> Which will force a line break in HTML.
>

or we could use a <p> to force a paragraph switch.
Thanks all for your help, I have it working now.


--
*************************************************************************** *****
* Usenet Impovement Project http://nacs.dyndns-office.com/usenet
* Bakers trade bread recipes on a knead-to-know basis.
*************************************************************************** ******
Re: Question about new lines [message #175496 is a reply to message #175489] Sun, 02 October 2011 19:08 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
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
Re: Question about new lines [message #175497 is a reply to message #175489] Sun, 02 October 2011 21:52 Go to previous messageGo to next message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma: 0
Senior Member
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)
Re: Question about new lines [message #175498 is a reply to message #175494] Sun, 02 October 2011 21:58 Go to previous messageGo to next message
Jeff Gaines is currently offline  Jeff Gaines
Messages: 11
Registered: October 2011
Karma: 0
Junior Member
On 02/10/2011 in message <4e889326$0$5371$9a566e8b(at)news(dot)aliant(dot)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>

--
Jeff Gaines Wiltshire UK
All those who believe in psychokinesis raise my hand.
Re: Question about new lines [message #175500 is a reply to message #175496] Mon, 03 October 2011 00:57 Go to previous messageGo to next message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
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
Re: Question about new lines [message #175501 is a reply to message #175498] Mon, 03 October 2011 04:35 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Jeff Gaines wrote:
> On 02/10/2011 in message <4e889326$0$5371$9a566e8b(at)news(dot)aliant(dot)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
Re: Question about new lines [message #175503 is a reply to message #175489] Mon, 03 October 2011 05:15 Go to previous messageGo to next message
Gordon Burditt is currently offline  Gordon Burditt
Messages: 2
Registered: March 2011
Karma: 0
Junior Member
> 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.
Re: Question about new lines [message #175505 is a reply to message #175501] Mon, 03 October 2011 07:53 Go to previous messageGo to next message
Jeff Gaines is currently offline  Jeff Gaines
Messages: 11
Registered: October 2011
Karma: 0
Junior Member
On 03/10/2011 in message <j6be24$k8h$4(at)news(dot)albasani(dot)net> The Natural
Philosopher wrote:

> Jeff Gaines wrote:
>> On 02/10/2011 in message <4e889326$0$5371$9a566e8b(at)news(dot)aliant(dot)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

Really?

http://www.w3schools.com/tags/tag_p.asp

That would be an advantage of using <br /> for the OP.

--
Jeff Gaines Wiltshire UK
Indecision is the key to flexibility
Re: Question about new lines [message #175506 is a reply to message #175505] Mon, 03 October 2011 09:40 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Jeff Gaines wrote:

> The Natural Philosopher wrote:
>> Jeff Gaines wrote:
>>> On 02/10/2011 in message <4e889326$0$5371$9a566e8b(at)news(dot)aliant(dot)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
>
> Really?
>
> http://www.w3schools.com/tags/tag_p.asp

W3Schools can be safely and must be strongly recommended against for use as
a reliable resource on Web development. When in doubt, consult the official
Specifications:

<http://www.w3.org/TR/html401/struct/text.html#edef-P>

However, the P/p element does have an _end_ tag, and it is a good idea to
use it so that the paragraph will be delimited *explicitly*. In XHTML, it
is mandatory anyway, as XHTML is an application of XML and well-formedness
requires either an end tag or SHORTTAG syntax (as below).

> That would be an advantage of using <br /> for the OP.

<br /> is XHTML SHORTTAG (not considering HTML SHORTTAG, which is widely
disregarded by browsers); <br>, <bR>, <Br> or <BR> is HTML. PHP has the
nl2br() function to make printing newlines as BR/br elements in (X)HTML
easier.

BR/br usually suffices for debugging purposes. However, semantics are
important: If the intention is to make a paragraph, use the P/p element; if
it is to make an unconditional *line break* *within* *a* *text* *paragraph*,
use the BR/br element.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(at)news(dot)demon(dot)co(dot)uk>
Re: Question about new lines [message #175507 is a reply to message #175505] Mon, 03 October 2011 11:26 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/3/2011 3:53 AM, Jeff Gaines wrote:
> On 03/10/2011 in message <j6be24$k8h$4(at)news(dot)albasani(dot)net> The Natural
> Philosopher wrote:
>
>> Jeff Gaines wrote:
>>> On 02/10/2011 in message <4e889326$0$5371$9a566e8b(at)news(dot)aliant(dot)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
>
> Really?
>
> http://www.w3schools.com/tags/tag_p.asp
>
> That would be an advantage of using <br /> for the OP.
>

Which isn't valid on html - only xhtml or xml.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Question about new lines [message #175508 is a reply to message #175507] Mon, 03 October 2011 11:42 Go to previous messageGo to next message
Jeff Gaines is currently offline  Jeff Gaines
Messages: 11
Registered: October 2011
Karma: 0
Junior Member
On 03/10/2011 in message <j6c64g$joe$2(at)dont-email(dot)me> Jerry Stuckle wrote:

> Which isn't valid on html - only xhtml or xml.

There seems to be confusion about whether or not the / is optional. In
reality, of course, all browsers honour it.

--
Those are my principles – and if you don’t like them, well, I have
others.
(Groucho Marx)
Re: Question about new lines [message #175510 is a reply to message #175508] Mon, 03 October 2011 12:48 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/3/2011 7:42 AM, Jeff Gaines wrote:
> On 03/10/2011 in message <j6c64g$joe$2(at)dont-email(dot)me> Jerry Stuckle wrote:
>
>> Which isn't valid on html - only xhtml or xml.
>
> There seems to be confusion about whether or not the / is optional. In
> reality, of course, all browsers honour it.
>

Whether browsers honor it or not is immaterial. It is directly against
the HTML spec, and attempts to validate pages with such ops will fail.
Just because browsers currently support it does not mean future browsers
will support something that violates the spec. It's also very sloppy
programming.

You are much better off conforming to the spec so the browser doesn't
have to guess at what you want.

Additionally, <br> does not have the same effect as <p>...</p>.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Question about new lines [message #175512 is a reply to message #175508] Mon, 03 October 2011 12:51 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Jeff Gaines wrote:

> Jerry Stuckle wrote:
>> Which isn't valid on html - only xhtml or xml.
>
> There seems to be confusion about whether or not the / is optional.

Yes, that only *seems* to be so.

> In reality, of course, all browsers honour it.

Your logic is flawed. You simply cannot know about *all* browsers.

AISB, *some* browsers, perhaps the majority in terms of market share, do not
implement the SGML Declaration for HTML 4.01 [1] properly, which specifies
the SHORTTAG syntax for HTML so that `<br />' is equivalent to `<br>&gt;' in
HTML (that allows, for example `<h1/My Title/' instead of `<h1>My
Title</h1>') [2]. But the W3C Validator [3] does, which is why, e. g.,

<link … rel="…" … />

is _not_ a Valid HTML 4.01 fragment (as `&gt;' would be character data which
is not allowed within the `HEAD' element).

This has led to the *current* HTML5 Working Draft regarding the trailing `/'
between `<' and the corresponding `>' of a start tag as allowed and optional
in the HTML syntax of HTML5 [4,5]. But you SHOULD NOT rely on that
outside of HTML5, perhaps not even in HTML5 until it has become stable.


HTH

PointedEars
___________
[1] <http://www.w3.org/TR/html401/sgml/sgmldecl.html>
[2] <http://www.w3.org/MarkUp/html3/HTMLandSGML.html>
[3] <http://validator.w3.org/>
[4] <http://www.w3.org/TR/2011/WD-html5-20110525/syntax.html#start-tags>
[5] <http://www.w3.org/TR/2011/WD-html5-20110525/introduction.html#html-vs-
xhtml>
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Re: Question about new lines [message #175514 is a reply to message #175510] Mon, 03 October 2011 13:05 Go to previous messageGo to next message
Jeff Gaines is currently offline  Jeff Gaines
Messages: 11
Registered: October 2011
Karma: 0
Junior Member
On 03/10/2011 in message <j6cau7$hu5$1(at)dont-email(dot)me> Jerry Stuckle wrote:

> Whether browsers honor it or not is immaterial. It is directly against
> the HTML spec, and attempts to validate pages with such ops will fail.
> Just because browsers currently support it does not mean future browsers
> will support something that violates the spec. It's also very sloppy
> programming.

I use it on all my web sites and they all validate 100%.

--
Jeff Gaines Wiltshire UK
If you ever find something you like buy a lifetime supply because they
will stop making it
Re: Question about new lines [message #175515 is a reply to message #175514] Mon, 03 October 2011 13:49 Go to previous messageGo to next message
Robert Heller is currently offline  Robert Heller
Messages: 60
Registered: December 2010
Karma: 0
Member
At 3 Oct 2011 13:05:18 GMT "Jeff Gaines" <jgaines_newsid(at)yahoo(dot)co(dot)uk> wrote:

>
> On 03/10/2011 in message <j6cau7$hu5$1(at)dont-email(dot)me> Jerry Stuckle wrote:
>
>> Whether browsers honor it or not is immaterial. It is directly against
>> the HTML spec, and attempts to validate pages with such ops will fail.
>> Just because browsers currently support it does not mean future browsers
>> will support something that violates the spec. It's also very sloppy
>> programming.
>
> I use it on all my web sites and they all validate 100%.

They would with a DOCTYPE like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Note: 'XHTML' above...

*XHTML* requires the </p> tag and <br /> and would raise at least a
warning if </p> were missing or there were br's with out the / (<br>).

Plain HTML4 does not need the </p> and should not support the <br />
tags (whether browsers browsers honor it or not).


--
Robert Heller -- 978-544-6933 / heller(at)deepsoft(dot)com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments
Re: Question about new lines [message #175516 is a reply to message #175515] Mon, 03 October 2011 14:11 Go to previous messageGo to next message
Jeff Gaines is currently offline  Jeff Gaines
Messages: 11
Registered: October 2011
Karma: 0
Junior Member
On 03/10/2011 in message
<PqednU2_ou72IBTTnZ2dnUVZ_tmdnZ2d(at)posted(dot)localnet> Robert Heller wrote:

> They would with a DOCTYPE like this:

It's actually:
<!DOCTYPE html>

As I don't see any point in using anything other than HTML5 on new pages
nowadays.

The start page should be:
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.jgaines.me.uk%2Findex.ph p

The "Album" page is a mess at the moment, but will have to wait a while to
be sorted.

--
Jeff Gaines Wiltshire UK
If it's not broken, mess around with it until it is
Re: Question about new lines [message #175517 is a reply to message #175514] Mon, 03 October 2011 14:54 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/3/2011 9:05 AM, Jeff Gaines wrote:
> On 03/10/2011 in message <j6cau7$hu5$1(at)dont-email(dot)me> Jerry Stuckle wrote:
>
>> Whether browsers honor it or not is immaterial. It is directly against
>> the HTML spec, and attempts to validate pages with such ops will fail.
>> Just because browsers currently support it does not mean future
>> browsers will support something that violates the spec. It's also very
>> sloppy programming.
>
> I use it on all my web sites and they all validate 100%.
>

What are you using for a doctype? Obviously not html.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Question about new lines [message #175518 is a reply to message #175516] Mon, 03 October 2011 14:57 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/3/2011 10:11 AM, Jeff Gaines wrote:
> On 03/10/2011 in message
> <PqednU2_ou72IBTTnZ2dnUVZ_tmdnZ2d(at)posted(dot)localnet> Robert Heller wrote:
>
>> They would with a DOCTYPE like this:
>
> It's actually:
> <!DOCTYPE html>
>
> As I don't see any point in using anything other than HTML5 on new pages
> nowadays.
>
> The start page should be:
> http://validator.w3.org/check?uri=http%3A%2F%2Fwww.jgaines.me.uk%2Findex.ph p
>
>
> The "Album" page is a mess at the moment, but will have to wait a while
> to be sorted.
>

Info Using experimental feature: HTML5 Conformance Checker.

The validator checked your document with an experimental feature:
HTML5 Conformance Checker. This feature has been made available for your
convenience, but be aware that it may be unreliable, or not perfectly up
to date with the latest development of some cutting-edge technologies.
If you find any issues with this feature, please report them. Thank you.

Plus your DOCTYPE does not list a DTD

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Question about new lines [message #175519 is a reply to message #175518] Mon, 03 October 2011 15:14 Go to previous messageGo to next message
Jeff Gaines is currently offline  Jeff Gaines
Messages: 11
Registered: October 2011
Karma: 0
Junior Member
On 03/10/2011 in message <j6cigo$4r5$3(at)dont-email(dot)me> Jerry Stuckle wrote:

> On 10/3/2011 10:11 AM, Jeff Gaines wrote:
>> On 03/10/2011 in message
>> <PqednU2_ou72IBTTnZ2dnUVZ_tmdnZ2d(at)posted(dot)localnet> Robert Heller wrote:
>>
>>> They would with a DOCTYPE like this:
>>
>> It's actually:
>> <!DOCTYPE html>
>>
>> As I don't see any point in using anything other than HTML5 on new pages
>> nowadays.
>>
>> The start page should be:
>> http://validator.w3.org/check?uri=http%3A%2F%2Fwww.jgaines.me.uk%2Findex.ph p
>>
>>
>> The "Album" page is a mess at the moment, but will have to wait a while
>> to be sorted.
>>
>
> Info Using experimental feature: HTML5 Conformance Checker.
>
> The validator checked your document with an experimental feature: HTML5
> Conformance Checker. This feature has been made available for your
> convenience, but be aware that it may be unreliable, or not perfectly up
> to date with the latest development of some cutting-edge technologies. If
> you find any issues with this feature, please report them. Thank you.
>

It's the best available at the moment.

> Plus your DOCTYPE does not list a DTD

Not needed, it's HTML5.

--
Jeff Gaines Wiltshire UK
The facts, although interesting, are irrelevant
Re: Question about new lines [message #175521 is a reply to message #175519] Mon, 03 October 2011 18:57 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/3/2011 11:14 AM, Jeff Gaines wrote:
> On 03/10/2011 in message <j6cigo$4r5$3(at)dont-email(dot)me> Jerry Stuckle wrote:
>
>> On 10/3/2011 10:11 AM, Jeff Gaines wrote:
>>> On 03/10/2011 in message
>>> <PqednU2_ou72IBTTnZ2dnUVZ_tmdnZ2d(at)posted(dot)localnet> Robert Heller wrote:
>>>
>>>> They would with a DOCTYPE like this:
>>>
>>> It's actually:
>>> <!DOCTYPE html>
>>>
>>> As I don't see any point in using anything other than HTML5 on new pages
>>> nowadays.
>>>
>>> The start page should be:
>>> http://validator.w3.org/check?uri=http%3A%2F%2Fwww.jgaines.me.uk%2Findex.ph p
>>>
>>>
>>>
>>> The "Album" page is a mess at the moment, but will have to wait a while
>>> to be sorted.
>>>
>>
>> Info Using experimental feature: HTML5 Conformance Checker.
>>
>> The validator checked your document with an experimental feature:
>> HTML5 Conformance Checker. This feature has been made available for
>> your convenience, but be aware that it may be unreliable, or not
>> perfectly up to date with the latest development of some cutting-edge
>> technologies. If you find any issues with this feature, please report
>> them. Thank you.
>>
>
> It's the best available at the moment.
>

Which doesn't mean it is correct.

>> Plus your DOCTYPE does not list a DTD
>
> Not needed, it's HTML5.
>


Ah, yes. The "floating standard". I'll start using it when they stop
changing the standards (and browsers have better support for it).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Question about new lines [message #175528 is a reply to message #175489] Tue, 04 October 2011 13:38 Go to previous messageGo to next message
Michael Joel is currently offline  Michael Joel
Messages: 42
Registered: October 2011
Karma: 0
Member
On 02 Oct 2011 14:00:27 GMT, Linus Flustillbe
<admin(at)nacs(dot)dyndns-office(dot)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
Re: Question about new lines [message #175539 is a reply to message #175516] Wed, 05 October 2011 19:20 Go to previous messageGo to next message
Mason Barge is currently offline  Mason Barge
Messages: 5
Registered: November 2010
Karma: 0
Junior Member
On 3 Oct 2011 14:11:59 GMT, "Jeff Gaines" <jgaines_newsid(at)yahoo(dot)co(dot)uk>
wrote:

> On 03/10/2011 in message
> <PqednU2_ou72IBTTnZ2dnUVZ_tmdnZ2d(at)posted(dot)localnet> Robert Heller wrote:
>
>> They would with a DOCTYPE like this:
>
> It's actually:
> <!DOCTYPE html>
>
> As I don't see any point in using anything other than HTML5 on new pages
> nowadays.

I use HTML 5 too. It's really nice after all the XHTML, LOL.

But question: Don't you need to use XHTML if you want to feed the page in
XML via RSS? Or at least, isn't it convenient to be able to validate it
so easily?
Re: Question about new lines [message #175545 is a reply to message #175501] Thu, 06 October 2011 11:21 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <j6be24$k8h$4(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> Jeff Gaines wrote:
>> On 02/10/2011 in message <4e889326$0$5371$9a566e8b(at)news(dot)aliant(dot)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
Re: Question about new lines [message #175546 is a reply to message #175516] Thu, 06 October 2011 11:27 Go to previous message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <xn0hjx75pp8xlpr01x(at)news(dot)individual(dot)net>,
"Jeff Gaines" <jgaines_newsid(at)yahoo(dot)co(dot)uk> wrote:

> On 03/10/2011 in message
> <PqednU2_ou72IBTTnZ2dnUVZ_tmdnZ2d(at)posted(dot)localnet> Robert Heller wrote:
>
>> They would with a DOCTYPE like this:
>
> It's actually:
> <!DOCTYPE html>
>
> As I don't see any point in using anything other than HTML5 on new pages
> nowadays.

Indeed, xhtml is dead so don't bother with it any more.

So, no more of this <br /> nonsense.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: comparing dates?
Next Topic: hai
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 21:19:14 GMT 2024

Total time taken to generate the page: 0.02477 seconds