Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #16818 > unrolled thread
| Started by | Alla <modelling.data@gmail.com> |
|---|---|
| First post | 2016-07-04 03:06 -0700 |
| Last post | 2016-07-31 08:17 +0200 |
| Articles | 19 — 10 participants |
Back to article view | Back to comp.lang.php
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
| From | Alla <modelling.data@gmail.com> |
|---|---|
| Date | 2016-07-04 03:06 -0700 |
| Subject | echo "<br>" wouldn't print a new line |
| Message-ID | <83e11700-3227-43a8-bf36-ab77004976e6@googlegroups.com> |
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?
Here is the program:
<?php
//access to function parameters
function foo()
{
$args = func_get_args();
print_r($args);
echo "<br>";
echo $args[0];
}
foo ("first", 33, true, 77.77);
?>
and here is how the output looks on my Termnal - the "first" is not being printed on a new line:
Array
(
[0] => first
[1] => 33
[2] => 1
[3] => 77.77
)
<br>first
Thank you!
[toc] | [next] | [standalone]
| From | "R.Wieser" <address@not.available> |
|---|---|
| Date | 2016-07-04 12:14 +0200 |
| Message-ID | <577a3655$0$5945$e4fe514c@news.xs4all.nl> |
| In reply to | #16818 |
Alla,
> and here is how the output looks on my Termnal - the "first"
> is not being printed on a new line:
The problem is most likely because that page does not start with a "<html>"
tag, causing your browser to regard the contents as a textfile.
In other words: you need to echo "<html>" at the top of your code, and
"</html>" at the bottom of it.
Regards,
Rudy Wieser
-- Origional message:
Alla <modelling.data@gmail.com> schreef in berichtnieuws
83e11700-3227-43a8-bf36-ab77004976e6@googlegroups.com...
> 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?
>
> Here is the program:
>
> <?php
> file://access to function parameters
> function foo()
> {
>
> $args = func_get_args();
> print_r($args);
> echo "<br>";
> echo $args[0];
> }
>
> foo ("first", 33, true, 77.77);
> ?>
>
> and here is how the output looks on my Termnal - the "first" is not being
printed on a new line:
>
> Array
> (
> [0] => first
> [1] => 33
> [2] => 1
> [3] => 77.77
> )
> <br>first
>
> Thank you!
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2016-07-04 12:19 +0200 |
| Message-ID | <nldd7c$so7$1@solani.org> |
| In reply to | #16818 |
On 04.07.2016 at 12:06, Alla wrote: > 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? > > […] > and here is how the output looks on my Termnal - the "first" is not being printed on a new line: `echo` just prints the arguments it's given. There's no magic involved. `echo <br>` will never print a new line. Only when that is part of a HTML document, the browser will display a line break. What you're looking for is "\n" or "\r\n" (for Windows, but often not necessary) or PHP_EOL (platform independent). Note that the escape sequences \n and \r are also available in C (printf etc.). -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2016-07-05 21:43 +0200 |
| Message-ID | <11587625.uLZWGnKmhe@PointedEars.de> |
| In reply to | #16821 |
Christoph M. Becker wrote:
> On 04.07.2016 at 12:06, Alla wrote:
>> I am currently learning C programming, and still a newby, but I have also
_newbie_
>> started php. I will be grateful for your help.
_PHP_
>> 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?
>>
>> […]
>
>> and here is how the output looks on my Termnal - the "first" is not being
>> printed on a new line:
>
> `echo` just prints the arguments it's given. There's no magic involved.
There is, literally, a little bit of magic involved: “echo” and “print”
print their respective arguments as if they had been typecast to string.
That is, if you are “echo”ing or “print”ing an object, and that object
inherits a “magic” __toString() method, then the return value of that method
(typecast to string if necessary), is printed:
$ php -r 'class C { function __toString () { return "42"; }} echo new C();
echo PHP_EOL;'
42
$ php -r 'class C { function __toString () { return "42"; }} print new C();
echo PHP_EOL;'
42
The difference between “echo” and “print” is that “print” returns 1 and can
be used as if it were a function.
<http://php.net/manual/en/language.oop5.magic.php#object.tostring>
<http://php.net/echo>
<http://php.net/print>
> `echo <br>` will never print a new line.
Well, to begin with, that is _not_ what *they* used.
> Only when that is part of a HTML document, the browser will display a
> line break. […]
No, the way *you* wrote it, it is always a syntax error (the backticks
notwithstanding).
> ["\r", "\n", "\r\n", or PHP_EOL instead of '<br>']
You are right about that of course, but ISTM that you are missing the point:
Probably the OP is unaware that PHP can run in different environments, and
that the tutorial they are using contains exercises for the environment of a
HTML user agent as that is the most common way to use PHP, the PHP
*Hypertext* Preprocessor. Whereas the OP has attempted to run the code
using the Command-Line Interface (CLI) version of PHP since they are
accustomed to executing programs on the command line from the (little) C
development experience they have.
When one needs to convert newlines to HTML line breaks,
<http://php.net/nl2br> comes in handy. [However, one should avoid
generating consecutive “br” elements for paragraphs; paragraphs is what the
“p” element is for instead.]
--
PointedEars
Zend Certified PHP Engineer
<http://www.zend.com/en/yellow-pages/ZEND024953> | Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2016-07-06 13:49 +0200 |
| Message-ID | <nlir90$t8g$1@solani.org> |
| In reply to | #16826 |
On 05.07.2016 at 21:43, Thomas 'PointedEars' Lahn wrote: > Christoph M. Becker wrote: > >> `echo` just prints the arguments it's given. There's no magic involved. > > There is, literally, a little bit of magic involved: “echo” and “print” > print their respective arguments as if they had been typecast to string. > That is, if you are “echo”ing or “print”ing an object, and that object > inherits a “magic” __toString() method, then the return value of that method > (typecast to string if necessary), is printed: You're right, but I don't consider this to be really special behavior of echo/print. Actually that behavior is the same for all (built-in) functions and operators expecting (a) string(s). >> `echo <br>` will never print a new line. > > Well, to begin with, that is _not_ what *they* used. Thanks for correcting the typo. :) > Probably the OP is unaware that PHP can run in different environments, and > that the tutorial they are using contains exercises for the environment of a > HTML user agent as that is the most common way to use PHP, the PHP > *Hypertext* Preprocessor. Whereas the OP has attempted to run the code > using the Command-Line Interface (CLI) version of PHP since they are > accustomed to executing programs on the command line from the (little) C > development experience they have. Actually, I was aware of that, but I've chosen to ignore it, because PHP tutorials should mention that (at least as a side note). Unfortunately, many don't, and in my experience a lot of PHP programmers are not aware of the CLI SAPI, so it's probably a good idea to point that out. <http://php.net/manual/en/features.commandline.php> appears to be a good starting point for those not yet accustomed using the command line interface, which can save a lot of time (for instance, wrt. to quick experiments). -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2016-07-06 20:57 +0200 |
| Message-ID | <7190720.T7Z3S40VBb@PointedEars.de> |
| In reply to | #16830 |
Christoph M. Becker wrote: > On 05.07.2016 at 21:43, Thomas 'PointedEars' Lahn wrote: >> Christoph M. Becker wrote: >>> `echo` just prints the arguments it's given. There's no magic involved. >> >> There is, literally, a little bit of magic involved: “echo” and “print” >> print their respective arguments as if they had been typecast to string. >> That is, if you are “echo”ing or “print”ing an object, and that object >> inherits a “magic” __toString() method, then the return value of that >> method (typecast to string if necessary), is printed: > > You're right, but I don't consider this to be really special behavior of > echo/print. Actually that behavior is the same for all (built-in) > functions and operators expecting (a) string(s). It is *certainly* true for *some* of them. >>> `echo <br>` will never print a new line. >> >> Well, to begin with, that is _not_ what *they* used. > > Thanks for correcting the typo. :) Fun fact: If one writes it exactly as you did, it can work if the shell triggered by `…` (which would have to be POSIX-non-compliant) supports it. > <http://php.net/manual/en/features.commandline.php> appears to be a good > starting point for those not yet accustomed using the command line > interface, which can save a lot of time (for instance, wrt. to quick > experiments). ACK. -- PointedEars Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953> | Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Alla <modelling.data@gmail.com> |
|---|---|
| Date | 2016-07-04 09:38 -0700 |
| Message-ID | <4a420e98-7eba-4ee3-b1c4-ef0c84d9fb54@googlegroups.com> |
| In reply to | #16818 |
<snip> Thank you very much for your replies. Now I understand it. Yes, I have tried to concatenate '\n' to get a new line, and it worked surely; so I wondered why <br> didn't do the job ) A lot to learn )
[toc] | [prev] | [next] | [standalone]
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Date | 2016-07-04 12:30 +0100 |
| Message-ID | <040720161230110610%timstreater@greenbee.net> |
| In reply to | #16818 |
In article <83e11700-3227-43a8-bf36-ab77004976e6@googlegroups.com>,
Alla <modelling.data@gmail.com> wrote:
>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?
>
>Here is the program:
>
><?php
>//access to function parameters
> function foo()
> {
>
> $args = func_get_args();
> print_r($args);
> echo "<br>";
> echo $args[0];
> }
>
> foo ("first", 33, true, 77.77);
>?>
>
>and here is how the output looks on my Termnal - the "first" is not being
>printed on a new line:
>
>Array
>(
> [0] => first
> [1] => 33
> [2] => 1
> [3] => 77.77
>)
><br>first
How are you running PHP? If you are doing it in a Terminal window, then
you don't want "<br>", you want "\n".
<br> is used when, from a web page, you are sending a form to a web
server, and are using PHP on the webserver to create the response
webpage.
--
"A committee is a cul-de-sac down which ideas are lured and then
quietly strangled." - Sir Barnett Cocks (1907-1989)
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2016-07-09 17:43 +0200 |
| Message-ID | <cdc3e273-c515-bf32-628d-50e748d9b9fd@arnowelzel.de> |
| In reply to | #16818 |
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. -- Arno Welzel http://arnowelzel.de http://de-rec-fahrrad.de http://fahrradzukunft.de
[toc] | [prev] | [next] | [standalone]
| From | Sebastiaan Kop <sebastiaan@famkop.nl> |
|---|---|
| Date | 2016-07-24 16:14 +0000 |
| Message-ID | <nn2phv$1dtj$1@gioia.aioe.org> |
| In reply to | #16837 |
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. -- Thanks, Sebastiaan
[toc] | [prev] | [next] | [standalone]
| From | Lew Pitcher <lew.pitcher@digitalfreehold.ca> |
|---|---|
| Date | 2016-07-30 14:03 -0400 |
| Message-ID | <nniq4r$phe$1@dont-email.me> |
| In reply to | #16878 |
On Sunday July 24 2016 12:14, in comp.lang.php, "Sebastiaan Kop"
<sebastiaan@famkop.nl> 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.
>
See http://php.net/manual/en/reserved.constants.php
PHP_EOL (string)
The correct 'End Of Line' symbol for this platform.
Available since PHP 5.0.2
echo "<br/>".$PHP_EOL;
--
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request
[toc] | [prev] | [next] | [standalone]
| From | Jivanmukta <jivanmukta@poczta.onet.pl> |
|---|---|
| Date | 2016-07-30 20:08 +0200 |
| Message-ID | <nniqeo$1r1p$1@gioia.aioe.org> |
| In reply to | #16892 |
Lew Pitcher wrote: > echo "<br/>".$PHP_EOL; Should be without $ because it is constant, not variable: echo "<br/>" . PHP_EOL;
[toc] | [prev] | [next] | [standalone]
| From | Lew Pitcher <lew.pitcher@digitalfreehold.ca> |
|---|---|
| Date | 2016-07-30 17:18 -0400 |
| Message-ID | <nnj5ih$1ln$1@dont-email.me> |
| In reply to | #16893 |
On Saturday July 30 2016 14:08, in comp.lang.php, "Jivanmukta" <jivanmukta@poczta.onet.pl> wrote: > Lew Pitcher wrote: >> echo "<br/>".$PHP_EOL; > > Should be without $ because it is constant, not variable: > echo "<br/>" . PHP_EOL; Mea culpa I don't use that pattern very often. -- Lew Pitcher "In Skills, We Trust" PGP public key available upon request
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@not.available> |
|---|---|
| Date | 2016-07-31 13:28 +0200 |
| Message-ID | <579de060$0$900$e4fe514c@news.xs4all.nl> |
| In reply to | #16892 |
Lew, > The correct 'End Of Line' symbol for this platform. That is only important if its used to generate a file that is *not* viewed inside a webbrowser (which will normally accept several different EOL sequences and handle them correctly/as good as it can -- regardless of if its a HTML or "just a text" document). ... but in that case (generating a non-browser file) you most likely won't be using a "<br>".PHP_EOL combination anyway. :-) And pardon me, but what a sh*tty PHP.NET description/explanation: I initially regarded that "this platform" as referring to the server the PHP code would be running on, and only a further search for what-the-heck it would than be good for caused me to realize that that it was ment to refer the one the *browser* would be running in. ... which both causes that "constant" only to be one inside the scope of the current request/outputted document (in other words, not a constant *at all*), and opens up another can of worms, as it needs to be inferred from the request-headers (which are ofcourse under full control of the user). Regards, Rudy Wieser -- origional message: Lew Pitcher <lew.pitcher@digitalfreehold.ca> schreef in berichtnieuws nniq4r$phe$1@dont-email.me... > On Sunday July 24 2016 12:14, in comp.lang.php, "Sebastiaan Kop" > <sebastiaan@famkop.nl> 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. > > > > See http://php.net/manual/en/reserved.constants.php > PHP_EOL (string) > The correct 'End Of Line' symbol for this platform. > Available since PHP 5.0.2 > > echo "<br/>".$PHP_EOL; > > -- > Lew Pitcher > "In Skills, We Trust" > PGP public key available upon request >
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2016-07-31 15:28 +0200 |
| Message-ID | <nnkudi$s2d$1@solani.org> |
| In reply to | #16897 |
On 31.07.2016 at 13:28, R.Wieser wrote: > And pardon me, but what a sh*tty PHP.NET description/explanation: I > initially regarded that "this platform" as referring to the server the PHP > code would be running on, and only a further search for what-the-heck it > would than be good for caused me to realize that that it was ment to refer > the one the *browser* would be running in. The PHP constant PHP_EOL is defined to be identical to the C constant PHP_EOL[1], which is set during *compile* time depending on whether the build happens on Windows or not[2]. So the PHP manual appears to be correct here. [1] <https://github.com/php/php-src/blob/PHP-7.0.9/main/main.c#L2137> [2] <https://github.com/php/php-src/blob/PHP-7.0.9/main/php.h#L48-L67> -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@not.available> |
|---|---|
| Date | 2016-07-31 17:38 +0200 |
| Message-ID | <579e1ae2$0$823$e4fe514c@news.xs4all.nl> |
| In reply to | #16898 |
Christoph, > ... which is set during *compile* time That makes the constant appear even more useless than I imagined ... ... only being of some, rather limited usage for PHP scripts that generate local files (that are to be read by programs that (still) cannot handle anything else than a single EOL style), that can/are ment to be transferred/used by PHP engines running in either a Unix/Linux or a Windows environment (which I imagine will not be many :-) ). > So the PHP manual appears to be correct here. I'm not sure which PHP manual you are referring to there. To me it certainly isn't in the one Lew linked too. Thanks for the links. Although the first one only shows a usage, the second one shows the constant to be defined as either of two EOL styles. Regards, Rudy Wieser -- Origional message: Christoph M. Becker <cmbecker69@arcor.de> schreef in berichtnieuws nnkudi$s2d$1@solani.org... > On 31.07.2016 at 13:28, R.Wieser wrote: > > > And pardon me, but what a sh*tty PHP.NET description/explanation: I > > initially regarded that "this platform" as referring to the server the PHP > > code would be running on, and only a further search for what-the-heck it > > would than be good for caused me to realize that that it was ment to refer > > the one the *browser* would be running in. > > The PHP constant PHP_EOL is defined to be identical to the C constant > PHP_EOL[1], which is set during *compile* time depending on whether the > build happens on Windows or not[2]. So the PHP manual appears to be > correct here. > > [1] <https://github.com/php/php-src/blob/PHP-7.0.9/main/main.c#L2137> > [2] <https://github.com/php/php-src/blob/PHP-7.0.9/main/php.h#L48-L67> > > -- > Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2016-08-01 14:57 +0200 |
| Message-ID | <nnngvq$gc$1@solani.org> |
| In reply to | #16900 |
On 31.07.2016 at 17:38, R.Wieser wrote: > Christoph M. Becker <cmbecker69@arcor.de> schreef in berichtnieuws > nnkudi$s2d$1@solani.org... > >> So the PHP manual appears to be correct here. > > I'm not sure which PHP manual you are referring to there. To me it > certainly isn't in the one Lew linked too. I was referring to <http://php.net/manual/en/reserved.constants.php>. Considering the nearby descriptions, the following seems to be more appropriate: | The correct 'End Of Line' symbol for this build of PHP. How would you word the description of PHP_EOL? > Thanks for the links. Although the first one only shows a usage, […] It's an important usage, though, namely that which makes PHP_EOL available to userland. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | "R.Wieser" <address@not.available> |
|---|---|
| Date | 2016-08-01 15:18 +0200 |
| Message-ID | <579f4b87$0$795$e4fe514c@news.xs4all.nl> |
| In reply to | #16902 |
Christoph, > Considering the nearby descriptions, the following seems to > be more appropriate: > > | The correct 'End Of Line' symbol for this build of PHP. Not really, as it now hinges on whats "correct" in regard to "this build" -- which cannot be inferred from the description. I think that something like the below would be more informative: "The correct 'End Of Line' symbol(s) for the platform the PHP engine is ment to run on: 0x0D,0x0A for Windows, 0x0A for Linux." > It's an important usage, though, namely that which makes > PHP_EOL available to userland. True, but its usage was already show in a previous post. :-) Regards, Rudy Wieser -- origional message: Christoph M. Becker <cmbecker69@arcor.de> schreef in berichtnieuws nnngvq$gc$1@solani.org... > On 31.07.2016 at 17:38, R.Wieser wrote: > > > Christoph M. Becker <cmbecker69@arcor.de> schreef in berichtnieuws > > nnkudi$s2d$1@solani.org... > > > >> So the PHP manual appears to be correct here. > > > > I'm not sure which PHP manual you are referring to there. To me it > > certainly isn't in the one Lew linked too. > > I was referring to <http://php.net/manual/en/reserved.constants.php>. > Considering the nearby descriptions, the following seems to be more > appropriate: > > | The correct 'End Of Line' symbol for this build of PHP. > > How would you word the description of PHP_EOL? > > > Thanks for the links. Although the first one only shows a usage, [.] > > It's an important usage, though, namely that which makes PHP_EOL > available to userland. > > -- > Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Date | 2016-07-31 08:17 +0200 |
| Message-ID | <e05jgoFcs4sU1@mid.individual.net> |
| In reply to | #16878 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web