# PHP_EOL exposed to scripts?

- Thread: https://externals.io/message/12096
- Original archive: https://news-web.php.net/php.internals/12096
- Started by Paul Hudson on 2004-08-11T23:22:41+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #12096 — Paul Hudson — 2004-08-11T23:22:41+00:00

URL: https://externals.io/message/12096#12096

Hi there,

This may already have been considered in the past, but I was wondering
whether the `PHP_EOL` constant available inside the PHP source code could be
made available to PHP programmers in their scripts?  The current solution
is, of course, to check `PHP_OS` each time and set the constant by hand, but
it would be nicer to have it pre-defined.

The cons are: 1) will break scripts that define their own PHP_EOL; and 2)
people might use it without realising it changes across platforms (duh?),
and rely on it to always be \n (or \r\n, etc);  3) Other cons?

Anyway, the patch is predictably easy: add this line in main.c, after the
definition for PHP_SHLIB_SUFFIX:

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

I've attached a diff, such as it is.

Thanks,


Paul

---

## #12097 — Andi Gutmans — 2004-08-12T03:03:18+00:00

URL: https://externals.io/message/12096#12097 · In reply to: #12096

I think it's a good idea. Personally I think that making this EOL would 
make it even easier to use.
We tend to prefix constants but in this case, we should probably consider 
not doing so because it could be part of the language.

Andi

At 12:22 AM 8/12/2004 +0100, Paul Hudson wrote:
>Hi there,
>
>This may already have been considered in the past, but I was wondering
>whether the `PHP_EOL` constant available inside the PHP source code could be
>made available to PHP programmers in their scripts?  The current solution
>is, of course, to check `PHP_OS` each time and set the constant by hand, but
>it would be nicer to have it pre-defined.
>
>The cons are: 1) will break scripts that define their own PHP_EOL; and 2)
>people might use it without realising it changes across platforms (duh?),
>and rely on it to always be \n (or \r\n, etc);  3) Other cons?
>
>Anyway, the patch is predictably easy: add this line in main.c, after the
>definition for PHP_SHLIB_SUFFIX:
>
>REGISTER_MAIN_STRINGL_CONSTANT("PHP_EOL", PHP_EOL, sizeof(PHP_EOL)-1,
>CONST_PERSISTENT | CONST_CS);
>
>I've attached a diff, such as it is.
>
>Thanks,
>
>
>Paul
