473,324 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Line terminator in php

Hello

The examples in the php cli chapter in the manual end a line with "\n".
For example
echo "Total {$total}.\n";
Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
systems ? And even "\r" on Macintosh ?

How to I get the end of line marker of the current platform ?

The PHP_EOL constant is the end of line marker on the system php was
build on, so if php was cross-compiled PHP_EOL would be different.
Is that right ?
Timothy Madden,
Romania.
Jun 2 '08 #1
21 5081
Timothy Madden wrote:
Hello

The examples in the php cli chapter in the manual end a line with "\n".
For example
echo "Total {$total}.\n";
Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
systems ? And even "\r" on Macintosh ?

How to I get the end of line marker of the current platform ?

The PHP_EOL constant is the end of line marker on the system php was
build on, so if php was cross-compiled PHP_EOL would be different.
Is that right ?
Timothy Madden,
Romania.
PHP is not compiled (it is interpreted), therefore it cannot be
cross-compiled. You install the script source on each system.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 2 '08 #2
On 20 May, 12:38, Jerry Stuckle <jstuck...@attglobal.netwrote:
Timothy Madden wrote:
Hello
The examples in the php cli chapter in the manual end a line with "\n".
For example
echo "Total {$total}.\n";
Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
systems ? And even "\r" on Macintosh ?
How to I get the end of line marker of the current platform ?
The PHP_EOL constant is the end of line marker on the system php was
build on, so if php was cross-compiled PHP_EOL would be different.
Is that right ?
Timothy Madden,
Romania.

PHP is not compiled (it is interpreted), therefore it cannot be
cross-compiled. You install the script source on each system.
He said: "The PHP_EOL constant is the end of line marker on the system
php was build on"
He means the system that the php executables were compiled on, not the
scripts.
Jun 2 '08 #3
Captain Paralytic wrote:
On 20 May, 12:38, Jerry Stuckle <jstuck...@attglobal.netwrote:
>Timothy Madden wrote:
>>Hello
The examples in the php cli chapter in the manual end a line with "\n".
For example
echo "Total {$total}.\n";
Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
systems ? And even "\r" on Macintosh ?
How to I get the end of line marker of the current platform ?
The PHP_EOL constant is the end of line marker on the system php was
build on, so if php was cross-compiled PHP_EOL would be different.
Is that right ?
Timothy Madden,
Romania.
PHP is not compiled (it is interpreted), therefore it cannot be
cross-compiled. You install the script source on each system.
He said: "The PHP_EOL constant is the end of line marker on the system
php was build on"
He means the system that the php executables were compiled on, not the
scripts.
Ah, I misunderstood the question.

The answer is, of course it would depend on the cross-compiler. I would
expect a properly functioning one to provide the correct terminator.

However, at the same time, "\n" should have the correct character(s) for
the platform PHP was compiled on, and should be all that is needed.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 2 '08 #4
Timothy Madden escribió:
The PHP_EOL constant is the end of line marker on the system php was
build on, so if php was cross-compiled PHP_EOL would be different.
Is that right ?
I was curious about it so I did some research (although my C skills are
pretty primitive).

The PHP constant is defined "main/main.c":

REGISTER_MAIN_STRINGL_CONSTANT("PHP_EOL", PHP_EOL, sizeof(PHP_EOL)-1,
CONST_PERSISTENT | CONST_CS);

The C constant it comes from is defined in "main/php.h":

#ifdef PHP_WIN32
#include "tsrm_win32.h"
#include "win95nt.h"
# ifdef PHP_EXPORTS
# define PHPAPI __declspec(dllexport)
# else
# define PHPAPI __declspec(dllimport)
# endif
#define PHP_DIR_SEPARATOR '\\'
#define PHP_EOL "\r\n"
#else
#define PHPAPI
#define THREAD_LS
#define PHP_DIR_SEPARATOR '/'
#if defined(__MacOSX__)
#define PHP_EOL "\r"
#else
#define PHP_EOL "\n"
#endif
#endif

Constants PHP_WIN32 and __MacOSX__ (if they *are* constants, I only
studied some basic C at university) are used all throughout the source
code to do platform specific tasks in the implementation of PHP
functions such as exec() or glob().

So my hypothesis is that if PHP_EOL doesn't have the correct value it'll
be the smallest of your problems.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jun 2 '08 #5
Jerry Stuckle wrote:
Captain Paralytic wrote:
>On 20 May, 12:38, Jerry Stuckle <jstuck...@attglobal.netwrote:
>>Timothy Madden wrote:
Hello
The examples in the php cli chapter in the manual end a line with "\n".
For example
echo "Total {$total}.\n";
Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
systems ? And even "\r" on Macintosh ?
[...]
>
However, at the same time, "\n" should have the correct character(s) for
the platform PHP was compiled on, and should be all that is needed.
Like the C library does ? I though about it, but I could not find it in
the php manual.

Thank you,
Timothy Madden,
Romania
Jun 2 '08 #6
Álvaro G. Vicario wrote:
Timothy Madden escribió:
>The PHP_EOL constant is the end of line marker on the system php was
build on, so if php was cross-compiled PHP_EOL would be different.
Is that right ?

I was curious about it so I did some research (although my C skills are
pretty primitive).

The PHP constant is defined "main/main.c":

REGISTER_MAIN_STRINGL_CONSTANT("PHP_EOL", PHP_EOL, sizeof(PHP_EOL)-1,
CONST_PERSISTENT | CONST_CS);

The C constant it comes from is defined in "main/php.h":

#ifdef PHP_WIN32
#include "tsrm_win32.h"
#include "win95nt.h"
# ifdef PHP_EXPORTS
# define PHPAPI __declspec(dllexport)
# else
# define PHPAPI __declspec(dllimport)
# endif
#define PHP_DIR_SEPARATOR '\\'
#define PHP_EOL "\r\n"
#else
#define PHPAPI
#define THREAD_LS
#define PHP_DIR_SEPARATOR '/'
#if defined(__MacOSX__)
#define PHP_EOL "\r"
#else
#define PHP_EOL "\n"
#endif
#endif

Constants PHP_WIN32 and __MacOSX__ (if they *are* constants, I only
studied some basic C at university) are used all throughout the source
code to do platform specific tasks in the implementation of PHP
functions such as exec() or glob().

So my hypothesis is that if PHP_EOL doesn't have the correct value it'll
be the smallest of your problems.

Thank you.

So saying PHP_EOL is the end-of-line marker for the system php was built
on is not entirely accurate.

Timothy Madden,
Romania
Jun 2 '08 #7
Timothy Madden wrote:
Jerry Stuckle wrote:
>Captain Paralytic wrote:
>>On 20 May, 12:38, Jerry Stuckle <jstuck...@attglobal.netwrote:
Timothy Madden wrote:
Hello
The examples in the php cli chapter in the manual end a line with
"\n".
For example
echo "Total {$total}.\n";
Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
systems ? And even "\r" on Macintosh ?
[...]
>>
However, at the same time, "\n" should have the correct character(s)
for the platform PHP was compiled on, and should be all that is needed.

Like the C library does ? I though about it, but I could not find it in
the php manual.

Thank you,
Timothy Madden,
Romania
It's a new line character. So it needs to insert whatever is a new line
on the OS it's compiled for.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 2 '08 #8
Greetings, Jerry Stuckle.
In reply to Your message dated Thursday, May 22, 2008, 16:38:47,
>>>>>The examples in the php cli chapter in the manual end a line with
>"\n".
>For example
> echo "Total {$total}.\n";
>Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
>systems ? And even "\r" on Macintosh ?
[...]
>>>
However, at the same time, "\n" should have the correct character(s)
for the platform PHP was compiled on, and should be all that is needed.

Like the C library does ? I though about it, but I could not find it in
the php manual.
It's a new line character. So it needs to insert whatever is a new line
on the OS it's compiled for.
I think you aren't connected your sentences properly.
"Newline character" is the chr(0x10) always. It is it's name.
"a new line on the OS" I suppose you mean the EOL character sequence.

Been that, a quick test revealed the issue (I've done it on Windows):

<?php

if("\n" === PHP_EOL)
{
echo 'Yup'.PHP_EOL;
}
else
{
echo 'Nop'.PHP_EOL;
}

?>

It echoing "Nop\r\n" as expected, because in Windows PHP_EOL equals to "\r\n"
exactly.
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 27 '08 #9
Greetings, Timothy Madden.
In reply to Your message dated Thursday, May 22, 2008, 13:52:22,
So saying PHP_EOL is the end-of-line marker for the system php was built
on is not entirely accurate.
It can be built on linux with Win32 as target platform... :)
More accurate statement would be
"PHP_EOL is the line-ending sequence for the OS the PHP are running on"
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 27 '08 #10
"Newline character" is the chr(0x10) always. It is it's name.

0x0A that is. Sorry me.
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 27 '08 #11
AnrDaemon wrote:
Greetings, Jerry Stuckle.
In reply to Your message dated Thursday, May 22, 2008, 16:38:47,
>>>>>>The examples in the php cli chapter in the manual end a line with
>>"\n".
>>For example
>> echo "Total {$total}.\n";
>>Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
>>systems ? And even "\r" on Macintosh ?
[...]
However, at the same time, "\n" should have the correct character(s)
for the platform PHP was compiled on, and should be all that is needed.

Like the C library does ? I though about it, but I could not find it in
the php manual.
>It's a new line character. So it needs to insert whatever is a new line
on the OS it's compiled for.

I think you aren't connected your sentences properly.
"Newline character" is the chr(0x10) always. It is it's name.
"a new line on the OS" I suppose you mean the EOL character sequence.
NO, NO, NO! "\n" is considered a newline character in C/C++, Java and
PHP. It is translated by the compiler to the correct line terminator,
depending on the OS.
Been that, a quick test revealed the issue (I've done it on Windows):

<?php

if("\n" === PHP_EOL)
{
echo 'Yup'.PHP_EOL;
}
else
{
echo 'Nop'.PHP_EOL;
}

?>

It echoing "Nop\r\n" as expected, because in Windows PHP_EOL equals to "\r\n"
exactly.

That's right. And in PHP that is indicated by "\n" - NOT "\r\n".
"\r\n" gives you x0a0d0a. The correct terminator is x0d0a.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 27 '08 #12
AnrDaemon wrote:
>"Newline character" is the chr(0x10) always. It is it's name.

0x0A that is. Sorry me.
.....or even more simpley chr(10) (since most of us, even those of us
familiar with hex), are more comfortable with decimal)
Jun 27 '08 #13
Greetings, Jerry Stuckle.
In reply to Your message dated Thursday, June 5, 2008, 05:30:07,
>>>>>>>The examples in the php cli chapter in the manual end a line with
>>>"\n".
>>>For example
>>> echo "Total {$total}.\n";
>>>Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
>>>systems ? And even "\r" on Macintosh ?
[...]
However, at the same time, "\n" should have the correct character(s)
for the platform PHP was compiled on, and should be all that is needed.
>
Like the C library does ? I though about it, but I could not find it in
the php manual.
>>It's a new line character. So it needs to insert whatever is a new line
on the OS it's compiled for.

I think you aren't connected your sentences properly.
"Newline character" is the chr(0x10) always. It is it's name.
"a new line on the OS" I suppose you mean the EOL character sequence.
NO, NO, NO! "\n" is considered a newline character in C/C++, Java and
PHP. It is translated by the compiler to the correct line terminator,
depending on the OS.
>Been that, a quick test revealed the issue (I've done it on Windows):

<?php

if("\n" === PHP_EOL)
{
echo 'Yup'.PHP_EOL;
}
else
{
echo 'Nop'.PHP_EOL;
}

?>

It echoing "Nop\r\n" as expected, because in Windows PHP_EOL equals to "\r\n"
exactly.
That's right. And in PHP that is indicated by "\n" - NOT "\r\n".
"\r\n" gives you x0a0d0a. The correct terminator is x0d0a.
Read code again... even in Windows, "\n" does NOT match the PHP_EOL.
\n == \n
PHP_EOL(in Windows) == \r\n
No single compiler will translate \n to \r\n.
\n is a chr(10) and nothing more.
chr(10) will never be equal to 2 characters, what "\r\n" is.

#include <stdio.h>
#include <windows.h>

int main ()
{
printf("%s", "\n");
}

Good luck testing!
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 27 '08 #14
AnrDaemon wrote:
Greetings, Jerry Stuckle.
In reply to Your message dated Thursday, June 5, 2008, 05:30:07,
>>>>>>>>The examples in the php cli chapter in the manual end a line with
>>>>"\n".
>>>>For example
>>>> echo "Total {$total}.\n";
>>>>Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
>>>>systems ? And even "\r" on Macintosh ?
[...]
>However, at the same time, "\n" should have the correct character(s)
>for the platform PHP was compiled on, and should be all that is needed.
>>
Like the C library does ? I though about it, but I could not find it in
the php manual.
It's a new line character. So it needs to insert whatever is a new line
on the OS it's compiled for.
I think you aren't connected your sentences properly.
"Newline character" is the chr(0x10) always. It is it's name.
"a new line on the OS" I suppose you mean the EOL character sequence.
>NO, NO, NO! "\n" is considered a newline character in C/C++, Java and
PHP. It is translated by the compiler to the correct line terminator,
depending on the OS.
>>Been that, a quick test revealed the issue (I've done it on Windows):

<?php

if("\n" === PHP_EOL)
{
echo 'Yup'.PHP_EOL;
}
else
{
echo 'Nop'.PHP_EOL;
}

?>

It echoing "Nop\r\n" as expected, because in Windows PHP_EOL equals to "\r\n"
exactly.
>That's right. And in PHP that is indicated by "\n" - NOT "\r\n".
"\r\n" gives you x0a0d0a. The correct terminator is x0d0a.

Read code again... even in Windows, "\n" does NOT match the PHP_EOL.
\n == \n
PHP_EOL(in Windows) == \r\n
No single compiler will translate \n to \r\n.
\n is a chr(10) and nothing more.
chr(10) will never be equal to 2 characters, what "\r\n" is.

#include <stdio.h>
#include <windows.h>

int main ()
{
printf("%s", "\n");
}

Good luck testing!

I didn't say anything about PHP_EOL - and the original op didn't ask
about PHP_EOL. He asked about "\n", which is the question I answered.

Your post is just adding to confusion.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #15
Greetings, Jerry Stuckle.
In reply to Your message dated Saturday, June 7, 2008, 14:20:26,
AnrDaemon wrote:
>Greetings, Jerry Stuckle.
In reply to Your message dated Thursday, June 5, 2008, 05:30:07,
>>>>>>>>>The examples in the php cli chapter in the manual end a line with
>>>>>"\n".
>>>>>For example
>>>>> echo "Total {$total}.\n";
>>>>>Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
>>>>>systems ? And even "\r" on Macintosh ?
>[...]
>>However, at the same time, "\n" should have the correct character(s)
>>for the platform PHP was compiled on, and should be all that is needed.
>>>
>Like the C library does ? I though about it, but I could not find it in
>the php manual.
It's a new line character. So it needs to insert whatever is a new line
on the OS it's compiled for.
I think you aren't connected your sentences properly.
"Newline character" is the chr(0x10) always. It is it's name.
"a new line on the OS" I suppose you mean the EOL character sequence.
>>NO, NO, NO! "\n" is considered a newline character in C/C++, Java and
PHP. It is translated by the compiler to the correct line terminator,
depending on the OS.
>>>Been that, a quick test revealed the issue (I've done it on Windows):

<?php

if("\n" === PHP_EOL)
{
echo 'Yup'.PHP_EOL;
}
else
{
echo 'Nop'.PHP_EOL;
}

?>

It echoing "Nop\r\n" as expected, because in Windows PHP_EOL equals to "\r\n"
exactly.
>>That's right. And in PHP that is indicated by "\n" - NOT "\r\n".
"\r\n" gives you x0a0d0a. The correct terminator is x0d0a.

Read code again... even in Windows, "\n" does NOT match the PHP_EOL.
\n == \n
PHP_EOL(in Windows) == \r\n
No single compiler will translate \n to \r\n.
\n is a chr(10) and nothing more.
chr(10) will never be equal to 2 characters, what "\r\n" is.

#include <stdio.h>
#include <windows.h>

int main ()
{
printf("%s", "\n");
}

Good luck testing!

I didn't say anything about PHP_EOL - and the original op didn't ask
about PHP_EOL. He asked about "\n", which is the question I answered.
Your post is just adding to confusion.
Your answer was
It's a new line character. So it needs to insert whatever is a new line
on the OS it's compiled for.
And it is wrong.
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 27 '08 #16
AnrDaemon wrote:
Greetings, Jerry Stuckle.
In reply to Your message dated Saturday, June 7, 2008, 14:20:26,
>AnrDaemon wrote:
>>Greetings, Jerry Stuckle.
In reply to Your message dated Thursday, June 5, 2008, 05:30:07,

>>>>>>The examples in the php cli chapter in the manual end a line with
>>>>>>"\n".
>>>>>>For example
>>>>>> echo "Total {$total}.\n";
>>>>>>Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
>>>>>>systems ? And even "\r" on Macintosh ?
>>[...]
>>>However, at the same time, "\n" should have the correct character(s)
>>>for the platform PHP was compiled on, and should be all that is needed.
>>>>
>>Like the C library does ? I though about it, but I could not find it in
>>the php manual.
>It's a new line character. So it needs to insert whatever is a new line
>on the OS it's compiled for.
I think you aren't connected your sentences properly.
"Newline character" is the chr(0x10) always. It is it's name.
"a new line on the OS" I suppose you mean the EOL character sequence.
>
NO, NO, NO! "\n" is considered a newline character in C/C++, Java and
PHP. It is translated by the compiler to the correct line terminator,
depending on the OS.
Been that, a quick test revealed the issue (I've done it on Windows):
>
<?php
>
if("\n" === PHP_EOL)
{
echo 'Yup'.PHP_EOL;
}
else
{
echo 'Nop'.PHP_EOL;
}
>
?>
>
It echoing "Nop\r\n" as expected, because in Windows PHP_EOL equals to "\r\n"
exactly.
That's right. And in PHP that is indicated by "\n" - NOT "\r\n".
"\r\n" gives you x0a0d0a. The correct terminator is x0d0a.
Read code again... even in Windows, "\n" does NOT match the PHP_EOL.
\n == \n
PHP_EOL(in Windows) == \r\n
No single compiler will translate \n to \r\n.
\n is a chr(10) and nothing more.
chr(10) will never be equal to 2 characters, what "\r\n" is.

#include <stdio.h>
#include <windows.h>

int main ()
{
printf("%s", "\n");
}

Good luck testing!

>I didn't say anything about PHP_EOL - and the original op didn't ask
about PHP_EOL. He asked about "\n", which is the question I answered.
>Your post is just adding to confusion.

Your answer was
>It's a new line character. So it needs to insert whatever is a new line
on the OS it's compiled for.

And it is wrong.

Nope, you're wrong (as you are about 90% of the time). Try it out. In
Windows, "\n" is 0x0d0a.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #17
Greetings, Jerry Stuckle.
In reply to Your message dated Sunday, June 8, 2008, 21:46:22,
AnrDaemon wrote:
>Greetings, Jerry Stuckle.
In reply to Your message dated Saturday, June 7, 2008, 14:20:26,
>>AnrDaemon wrote:
Greetings, Jerry Stuckle.
In reply to Your message dated Thursday, June 5, 2008, 05:30:07,

>>>>>>>The examples in the php cli chapter in the manual end a line with
>>>>>>>"\n".
>>>>>>>For example
>>>>>>> echo "Total {$total}.\n";
>>>>>>>Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
>>>>>>>systems ? And even "\r" on Macintosh ?
>>>[...]
>>>>However, at the same time, "\n" should have the correct character(s)
>>>>for the platform PHP was compiled on, and should be all that is needed.
>>>>>
>>>Like the C library does ? I though about it, but I could not find it in
>>>the php manual.
>>It's a new line character. So it needs to insert whatever is a new line
>>on the OS it's compiled for.
>I think you aren't connected your sentences properly.
>"Newline character" is the chr(0x10) always. It is it's name.
>"a new line on the OS" I suppose you mean the EOL character sequence.
>>
NO, NO, NO! "\n" is considered a newline character in C/C++, Java and
PHP. It is translated by the compiler to the correct line terminator,
depending on the OS.
>Been that, a quick test revealed the issue (I've done it on Windows):
>>
><?php
>>
>if("\n" === PHP_EOL)
>{
> echo 'Yup'.PHP_EOL;
>}
>else
>{
> echo 'Nop'.PHP_EOL;
>}
>>
>?>
>>
>It echoing "Nop\r\n" as expected, because in Windows PHP_EOL equals to "\r\n"
>exactly.
That's right. And in PHP that is indicated by "\n" - NOT "\r\n".
"\r\n" gives you x0a0d0a. The correct terminator is x0d0a.
Read code again... even in Windows, "\n" does NOT match the PHP_EOL.
\n == \n
PHP_EOL(in Windows) == \r\n
No single compiler will translate \n to \r\n.
\n is a chr(10) and nothing more.
chr(10) will never be equal to 2 characters, what "\r\n" is.

#include <stdio.h>
#include <windows.h>

int main ()
{
printf("%s", "\n");
}

Good luck testing!

>>I didn't say anything about PHP_EOL - and the original op didn't ask
about PHP_EOL. He asked about "\n", which is the question I answered.
>>Your post is just adding to confusion.

Your answer was
>>It's a new line character. So it needs to insert whatever is a new line
on the OS it's compiled for.

And it is wrong.
Nope, you're wrong (as you are about 90% of the time). Try it out. In
Windows, "\n" is 0x0d0a.
Please point to compiler or scripting environment, in which the "\n" is a
"\r\n" under Windows.
I've tested C (gnu C 3.4.4), PHP 5.2.4
none of them converting \n to \r\n
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 27 '08 #18
AnrDaemon wrote:
Greetings, Jerry Stuckle.
In reply to Your message dated Sunday, June 8, 2008, 21:46:22,
>AnrDaemon wrote:
>>Greetings, Jerry Stuckle.
In reply to Your message dated Saturday, June 7, 2008, 14:20:26,

AnrDaemon wrote:
Greetings, Jerry Stuckle.
In reply to Your message dated Thursday, June 5, 2008, 05:30:07,
>
>>>>>>>>The examples in the php cli chapter in the manual end a line with
>>>>>>>>"\n".
>>>>>>>>For example
>>>>>>>> echo "Total {$total}.\n";
>>>>>>>>Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
>>>>>>>>systems ? And even "\r" on Macintosh ?
>>>>[...]
>>>>>However, at the same time, "\n" should have the correct character(s)
>>>>>for the platform PHP was compiled on, and should be all that is needed.
>>>>>>
>>>>Like the C library does ? I though about it, but I could not find it in
>>>>the php manual.
>>>It's a new line character. So it needs to insert whatever is a new line
>>>on the OS it's compiled for.
>>I think you aren't connected your sentences properly.
>>"Newline character" is the chr(0x10) always. It is it's name.
>>"a new line on the OS" I suppose you mean the EOL character sequence.
>>>
>NO, NO, NO! "\n" is considered a newline character in C/C++, Java and
>PHP. It is translated by the compiler to the correct line terminator,
>depending on the OS.
>>Been that, a quick test revealed the issue (I've done it on Windows):
>>>
>><?php
>>>
>>if("\n" === PHP_EOL)
>>{
>> echo 'Yup'.PHP_EOL;
>>}
>>else
>>{
>> echo 'Nop'.PHP_EOL;
>>}
>>>
>>?>
>>>
>>It echoing "Nop\r\n" as expected, because in Windows PHP_EOL equals to "\r\n"
>>exactly.
>That's right. And in PHP that is indicated by "\n" - NOT "\r\n".
>"\r\n" gives you x0a0d0a. The correct terminator is x0d0a.
Read code again... even in Windows, "\n" does NOT match the PHP_EOL.
\n == \n
PHP_EOL(in Windows) == \r\n
No single compiler will translate \n to \r\n.
\n is a chr(10) and nothing more.
chr(10) will never be equal to 2 characters, what "\r\n" is.
>
#include <stdio.h>
#include <windows.h>
>
int main ()
{
printf("%s", "\n");
}
>
Good luck testing!
>
>
I didn't say anything about PHP_EOL - and the original op didn't ask
about PHP_EOL. He asked about "\n", which is the question I answered.
Your post is just adding to confusion.
Your answer was

It's a new line character. So it needs to insert whatever is a new line
on the OS it's compiled for.
And it is wrong.
>Nope, you're wrong (as you are about 90% of the time). Try it out. In
Windows, "\n" is 0x0d0a.

Please point to compiler or scripting environment, in which the "\n" is a
"\r\n" under Windows.
I've tested C (gnu C 3.4.4), PHP 5.2.4
none of them converting \n to \r\n

C, C++, Java, PHP - I've used all of them, some for over 20 years. They
all use 0x0d0a on Windows.

And that is NOT the same as \r\n.

Get another job. You again have proven you are not suited to be a
programmer.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #19
Greetings, Jerry Stuckle.
In reply to Your message dated Sunday, June 8, 2008, 22:27:16,
AnrDaemon wrote:
>Greetings, Jerry Stuckle.
In reply to Your message dated Sunday, June 8, 2008, 21:46:22,
>>AnrDaemon wrote:
Greetings, Jerry Stuckle.
In reply to Your message dated Saturday, June 7, 2008, 14:20:26,

AnrDaemon wrote:
>Greetings, Jerry Stuckle.
>In reply to Your message dated Thursday, June 5, 2008, 05:30:07,
>>
>>>>>>>>>The examples in the php cli chapter in the manual end a line with
>>>>>>>>>"\n".
>>>>>>>>>For example
>>>>>>>>> echo "Total {$total}.\n";
>>>>>>>>>Should it not be "\n" on Linux\Unix systems and "\r\n" on Windows
>>>>>>>>>systems ? And even "\r" on Macintosh ?
>>>>>[...]
>>>>>>However, at the same time, "\n" should have the correct character(s)
>>>>>>for the platform PHP was compiled on, and should be all that is needed.
>>>>>>>
>>>>>Like the C library does ? I though about it, but I could not find it in
>>>>>the php manual.
>>>>It's a new line character. So it needs to insert whatever is a new line
>>>>on the OS it's compiled for.
>>>I think you aren't connected your sentences properly.
>>>"Newline character" is the chr(0x10) always. It is it's name.
>>>"a new line on the OS" I suppose you mean the EOL character sequence.
>>>>
>>NO, NO, NO! "\n" is considered a newline character in C/C++, Java and
>>PHP. It is translated by the compiler to the correct line terminator,
>>depending on the OS.
>>>Been that, a quick test revealed the issue (I've done it on Windows):
>>>>
>>><?php
>>>>
>>>if("\n" === PHP_EOL)
>>>{
>>> echo 'Yup'.PHP_EOL;
>>>}
>>>else
>>>{
>>> echo 'Nop'.PHP_EOL;
>>>}
>>>>
>>>?>
>>>>
>>>It echoing "Nop\r\n" as expected, because in Windows PHP_EOL equals to "\r\n"
>>>exactly.
>>That's right. And in PHP that is indicated by "\n" - NOT "\r\n".
>>"\r\n" gives you x0a0d0a. The correct terminator is x0d0a.
>Read code again... even in Windows, "\n" does NOT match the PHP_EOL.
>\n == \n
>PHP_EOL(in Windows) == \r\n
>No single compiler will translate \n to \r\n.
>\n is a chr(10) and nothing more.
>chr(10) will never be equal to 2 characters, what "\r\n" is.
>>
>#include <stdio.h>
>#include <windows.h>
>>
>int main ()
>{
> printf("%s", "\n");
>}
>>
>Good luck testing!
>>
>>
I didn't say anything about PHP_EOL - and the original op didn't ask
about PHP_EOL. He asked about "\n", which is the question I answered.
Your post is just adding to confusion.
Your answer was

It's a new line character. So it needs to insert whatever is a new line
on the OS it's compiled for.
And it is wrong.
>>Nope, you're wrong (as you are about 90% of the time). Try it out. In
Windows, "\n" is 0x0d0a.

Please point to compiler or scripting environment, in which the "\n" is a
"\r\n" under Windows.
I've tested C (gnu C 3.4.4), PHP 5.2.4
none of them converting \n to \r\n
C, C++, Java, PHP - I've used all of them, some for over 20 years. They
all use 0x0d0a on Windows.
And that is NOT the same as \r\n.
Again...

<?php echo "\n"; ?>

It printing 0x0a in windows.
What i'm doing wrong?
Get another job. You again have proven you are not suited to be a
programmer.
Well, tell me what i'm doing wrong, please. Or do I have error in my 1-line
script?
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 27 '08 #20
Greetings, Jerry Stuckle.
In reply to Your message dated Sunday, June 8, 2008, 22:27:16,
>AnrDaemon wrote:
>>Greetings, Jerry Stuckle.
In reply to Your message dated Sunday, June 8, 2008, 21:46:22,

AnrDaemon wrote:
Greetings, Jerry Stuckle.
In reply to Your message dated Saturday, June 7, 2008, 14:20:26,
>
>AnrDaemon wrote:
>>Greetings, Jerry Stuckle.
>>In reply to Your message dated Thursday, June 5, 2008, 05:30:07,
>>>
>>>>>>>>>>The examples in the php cli chapter in the manual end a
>>>>>>>>>>line with "\n".
>>>>>>>>>>For example
>>>>>>>>>> echo "Total {$total}.\n";
>>>>>>>>>>Should it not be "\n" on Linux\Unix systems and "\r\n"
>>>>>>>>>>on Windows systems ? And even "\r" on Macintosh ?
>>>>>>[...]
>>>>>>>However, at the same time, "\n" should have the correct
>>>>>>>character(s) for the platform PHP was compiled on, and
>>>>>>>should be all that is needed.
>>>>>>>>
>>>>>>Like the C library does ? I though about it, but I could
>>>>>>not find it in the php manual.
>>>>>It's a new line character. So it needs to insert whatever
>>>>>is a new line on the OS it's compiled for.
>>>>I think you aren't connected your sentences properly.
>>>>"Newline character" is the chr(0x10) always. It is it's name.
>>>>"a new line on the OS" I suppose you mean the EOL character
>>>>sequence.
>>>>>
>>>NO, NO, NO! "\n" is considered a newline character in C/C++,
>>>Java and PHP. It is translated by the compiler to the correct
>>>line terminator, depending on the OS.
>>>>Been that, a quick test revealed the issue (I've done it on
>>>>Windows):
>>>>>
>>>><?php
>>>>>
>>>>if("\n" === PHP_EOL)
>>>>{
>>>> echo 'Yup'.PHP_EOL;
>>>>}
>>>>else
>>>>{
>>>> echo 'Nop'.PHP_EOL;
>>>>}
>>>>>
>>>>>>
>>>>>
>>>>It echoing "Nop\r\n" as expected, because in Windows PHP_EOL
>>>>equals to "\r\n" exactly.
>>>That's right. And in PHP that is indicated by "\n" - NOT
>>>"\r\n". "\r\n" gives you x0a0d0a. The correct terminator is
>>>x0d0a.
>>Read code again... even in Windows, "\n" does NOT match the
>>PHP_EOL. \n == \n
>>PHP_EOL(in Windows) == \r\n
>>No single compiler will translate \n to \r\n.
>>\n is a chr(10) and nothing more.
>>chr(10) will never be equal to 2 characters, what "\r\n" is.
>>>
>>#include <stdio.h>
>>#include <windows.h>
>>>
>>int main ()
>>{
>> printf("%s", "\n");
>>}
>>>
>>Good luck testing!
>>>
>>>
>I didn't say anything about PHP_EOL - and the original op didn't
>ask about PHP_EOL. He asked about "\n", which is the question I
>answered. Your post is just adding to confusion.
Your answer was
>
>It's a new line character. So it needs to insert whatever is a
>new line on the OS it's compiled for.
And it is wrong.

Nope, you're wrong (as you are about 90% of the time). Try it
out. In Windows, "\n" is 0x0d0a.

Please point to compiler or scripting environment, in which the
"\n" is a "\r\n" under Windows.
I've tested C (gnu C 3.4.4), PHP 5.2.4
none of them converting \n to \r\n
>C, C++, Java, PHP - I've used all of them, some for over 20 years.
They all use 0x0d0a on Windows.
>And that is NOT the same as \r\n.

Again...

<?php echo "\n"; ?>

It printing 0x0a in windows.
What i'm doing wrong?
>Get another job. You again have proven you are not suited to be a
programmer.

Well, tell me what i'm doing wrong, please. Or do I have error in my
1-line script?
Ann's an idiot and about as sincere as the last turd to flush down my
toilet; no interest in helping anyone, only in trolling.
Jun 27 '08 #21
Greetings, Twayne.
In reply to Your message dated Monday, June 9, 2008, 05:39:43,
>>>>>>>>>>>>>>>The examples in the php cli chapter in the manual end a
>>>>>>>>>>>line with "\n".
>>>>>>>>>>>For example
>>>>>>>>>>> echo "Total {$total}.\n";
>>>>>>>>>>>Should it not be "\n" on Linux\Unix systems and "\r\n"
>>>>>>>>>>>on Windows systems ? And even "\r" on Macintosh ?
>>>>>>>[...]
>>>>>>>>However, at the same time, "\n" should have the correct
>>>>>>>>character(s) for the platform PHP was compiled on, and
>>>>>>>>should be all that is needed.
>>>>>>>>>
>>>>>>>Like the C library does ? I though about it, but I could
>>>>>>>not find it in the php manual.
>>>>>>It's a new line character. So it needs to insert whatever
>>>>>>is a new line on the OS it's compiled for.
>>>>>I think you aren't connected your sentences properly.
>>>>>"Newline character" is the chr(0x10) always. It is it's name.
>>>>>"a new line on the OS" I suppose you mean the EOL character
>>>>>sequence.
>>>>>>
>>>>NO, NO, NO! "\n" is considered a newline character in C/C++,
>>>>Java and PHP. It is translated by the compiler to the correct
>>>>line terminator, depending on the OS.
>>>>>Been that, a quick test revealed the issue (I've done it on
>>>>>Windows):
>>>>>>
>>>>><?php
>>>>>>
>>>>>if("\n" === PHP_EOL)
>>>>>{
>>>>> echo 'Yup'.PHP_EOL;
>>>>>}
>>>>>else
>>>>>{
>>>>> echo 'Nop'.PHP_EOL;
>>>>>}
>>>>>>
>>>>>>>
>>>>>>
>>>>>It echoing "Nop\r\n" as expected, because in Windows PHP_EOL
>>>>>equals to "\r\n" exactly.
>>>>That's right. And in PHP that is indicated by "\n" - NOT
>>>>"\r\n". "\r\n" gives you x0a0d0a. The correct terminator is
>>>>x0d0a.
>>>Read code again... even in Windows, "\n" does NOT match the
>>>PHP_EOL. \n == \n
>>>PHP_EOL(in Windows) == \r\n
>>>No single compiler will translate \n to \r\n.
>>>\n is a chr(10) and nothing more.
>>>chr(10) will never be equal to 2 characters, what "\r\n" is.
>>>>
>>>#include <stdio.h>
>>>#include <windows.h>
>>>>
>>>int main ()
>>>{
>>> printf("%s", "\n");
>>>}
>>>>
>>>Good luck testing!
>>>>
>>>>
>>I didn't say anything about PHP_EOL - and the original op didn't
>>ask about PHP_EOL. He asked about "\n", which is the question I
>>answered. Your post is just adding to confusion.
>Your answer was
>>
>>It's a new line character. So it needs to insert whatever is a
>>new line on the OS it's compiled for.
>And it is wrong.

Nope, you're wrong (as you are about 90% of the time). Try it
out. In Windows, "\n" is 0x0d0a.

Please point to compiler or scripting environment, in which the
"\n" is a "\r\n" under Windows.
I've tested C (gnu C 3.4.4), PHP 5.2.4
none of them converting \n to \r\n
>>C, C++, Java, PHP - I've used all of them, some for over 20 years.
They all use 0x0d0a on Windows.
>>And that is NOT the same as \r\n.

Again...

<?php echo "\n"; ?>

It printing 0x0a in windows.
What i'm doing wrong?
>>Get another job. You again have proven you are not suited to be a
programmer.

Well, tell me what i'm doing wrong, please. Or do I have error in my
1-line script?
Ann's an idiot and about as sincere as the last turd to flush down my
toilet; no interest in helping anyone, only in trolling.
Please apologise for my question, can you re-word your answer?
I haven't understand it clearly. English isn't my native language.
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 27 '08 #22

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: ajikoe | last post by:
Hello, I use windows notepad editor to write text. For example I write (in d:\myfile.txt): Helo World If I open it with python: FName = open(d:\myfile.txt,'r')
3
by: James | last post by:
Hello, I'm trying to execute a file containing few SQL statements. CREATE VIEW test1 AS SELECT * FROM table1; CREATE VIEW test2 AS SELECT * FROM table2; The standard SQL way is to end a...
3
by: Monica J. Braverman | last post by:
My client will be receiving a .dbf file which needs to be uploaded into a sql server database table (as an append) every week. They are NOT computer savvy and I would like to automate this process...
1
by: joshsackett | last post by:
Hello all, I have a multiple text files with an odd row terminator. If you were to examine it in VB it would be like a "CrCrLf" instead of just "CrLf". In HEX it is DDA instead of just DA. When I...
5
by: Mortimer | last post by:
Hi, I hope someone can help. I can't seem to find the answer to this anywhere. I need to change the SQL terminator from a semicolon (;) to an exclamation point within SPUFI in order to process a...
9
by: kernelxu | last post by:
hi,everybody. I calling function setbuf() to change the characteristic of standsrd input buffer. some fragment of the progrem is: (DEV-C++2.9.9.2) #include <stdio.h> #include <stdlib.h> int...
2
by: Laurent Laporte | last post by:
hello, I'm using cvs standard module under Python 2.3 / 2.4 to read a CSV file. The file is opened in binary mode, so I keep the end of line terminator. It appears that the csv.Sniffer force...
0
by: David Hirschfield | last post by:
I'm implementing a relatively simple inter-application communication system that uses asyncore/asynchat to send messages back and forth. The messages are prefixed by a length value and terminator...
2
by: kirbybowl | last post by:
I have been using --#SET TERMINATOR to change the delimiter within my CLP scripts. In my situation, the CLP scripts are generated from a database of CLP commands (written by many authors), thus the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.