Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #16896

Re: echo "<br>" wouldn't print a new line

From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: echo "<br>" wouldn't print a new line
Date 2016-07-31 08:17 +0200
Message-ID <e05jgoFcs4sU1@mid.individual.net> (permalink)
References <83e11700-3227-43a8-bf36-ab77004976e6@googlegroups.com> <cdc3e273-c515-bf32-628d-50e748d9b9fd@arnowelzel.de> <nn2phv$1dtj$1@gioia.aioe.org>

Show all headers | View raw


On 07/24/16 18:14, Sebastiaan Kop wrote:
> Arno Welzel <usenet@arnowelzel.de> wrote:
>> Alla, 2016-07-04 12:06:
>>
>>> Hello!
>>>
>>> I am currently learning C programming, and still a newby, but I have also started php.
>>> I will be grateful for your help.
>>>
>>> I have watched a tutorial for beginners on using some functions, and the author 
>>> used echo "<br>"; command to print a new line for the next output. I have tried it,
>>> but it didn't work. What could be the problem?
>>
>> The problem is that "<br>" is not a "new line", it is just the HTML
>> element for line break. Since PHP is often used to create HTML output
>> the tutorial may just refer to HTML and not console output.
>>
>> So if you want to output content as *HTML* then "<br>" is fine to have a
>> line break, but if you want to output plain text to a console or
>> text/plain to a browser, you need "\n" as in C as well.
>>
>>
> 
> I always use:
> 
> Echo "<br>\r\n";
> 
> This makes a new line in the html source also.


That can cause some trash characters at the end of the line, as "new
line" is quite operating system dependant. Sure you can use  PHP_EOL and
you will always get the right "new line" for the server, but may not be
true for the client.

The argument I have against the microsoft-windows "new line" is that it
uses twice as many bytes as the Unix one and more applications will
handle it correctly too.

In the end it's the purpose of the "new line" which dictates what you
should use.

-- 

 //Aho

Back to comp.lang.php | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

echo "<br>" wouldn't print a new line Alla <modelling.data@gmail.com> - 2016-07-04 03:06 -0700
  Re: echo "<br>" wouldn't print a new line "R.Wieser" <address@not.available> - 2016-07-04 12:14 +0200
  Re: echo "<br>" wouldn't print a new line "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-07-04 12:19 +0200
    Re: echo "<br>" wouldn't print a new line Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-07-05 21:43 +0200
      Re: echo "<br>" wouldn't print a new line "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-07-06 13:49 +0200
        Re: echo "<br>" wouldn't print a new line Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-07-06 20:57 +0200
  Re: echo "<br>" wouldn't print a new line Alla <modelling.data@gmail.com> - 2016-07-04 09:38 -0700
  Re: echo "<br>" wouldn't print a new line Tim Streater <timstreater@greenbee.net> - 2016-07-04 12:30 +0100
  Re: echo "<br>" wouldn't print a new line Arno Welzel <usenet@arnowelzel.de> - 2016-07-09 17:43 +0200
    Re: echo "<br>" wouldn't print a new line Sebastiaan Kop <sebastiaan@famkop.nl> - 2016-07-24 16:14 +0000
      Re: echo "<br>" wouldn't print a new line Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-07-30 14:03 -0400
        Re: echo "<br>" wouldn't print a new line Jivanmukta <jivanmukta@poczta.onet.pl> - 2016-07-30 20:08 +0200
          Re: echo "<br>" wouldn't print a new line Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-07-30 17:18 -0400
        Re: echo "<br>" wouldn't print a new line "R.Wieser" <address@not.available> - 2016-07-31 13:28 +0200
          Re: echo "<br>" wouldn't print a new line "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-07-31 15:28 +0200
            Re: echo "<br>" wouldn't print a new line "R.Wieser" <address@not.available> - 2016-07-31 17:38 +0200
              Re: echo "<br>" wouldn't print a new line "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-08-01 14:57 +0200
                Re: echo "<br>" wouldn't print a new line "R.Wieser" <address@not.available> - 2016-08-01 15:18 +0200
      Re: echo "<br>" wouldn't print a new line "J.O. Aho" <user@example.net> - 2016-07-31 08:17 +0200

csiph-web