Re: Newline
| From: | Nathan Nobbe | Date: | Tue, 30 Oct 2007 04:42:25 +0000 |
| Subject: | Re: Newline | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263797@lists.php.net to get a copy of this message | ||
On 10/30/07, Crayon Shin Chan <crayon.shin.chan.uk@gmail.com> wrote:
>
> On Monday 29 October 2007, Nathan Nobbe wrote:
> > if you were going to do that you may as well use PHP_EOL
> > its cross-platform and doesnt require an define directive.
> > (php5 only)
>
> It's available in 4.3.10 as well,
youre right about that; my mistake.
but manual doesn't specify what it
> defines -
let the source tell it:
phpunpack/php5.2-200708051230/NEWS:2867:- Added PHP_EOL constant that
contains the OS way of representing newlines.
47 #ifdef PHP_WIN32
48 #include "tsrm_win32.h"
49 #include "win95nt.h"
50 # ifdef PHP_EXPORTS
51 # define PHPAPI __declspec(dllexport)
52 # else
53 # define PHPAPI __declspec(dllimport)
54 # endif
55 #define PHP_DIR_SEPARATOR '\\'
56 #define PHP_EOL "\r\n"
57 #else
58 #define PHPAPI
59 #define THREAD_LS
60 #define PHP_DIR_SEPARATOR '/'
61 #if defined(__MacOSX__)
62 #define PHP_EOL "\r"
63 #else
64 #define PHP_EOL "\n"
65 #endif
66 #endif
I suppose I can echo or vardump it to find out.
a little trickier than you might guess :
php > var_dump(PHP_EOL);
string(1) "
"
Also manual
> doesn't mention "cross-platform", in any case even if it
> is "cross-platform" it seems pointless because how does PHP know which
> environment the output is going to be used in?
its supposed to be used for the command line;
theoretically the output will land on the same system from which its
generated.
however, coming from my linux box; this was correctly interpreted by
internet explorer
<?php
echo 'blah' . PHP_EOL . 'blah';
?>
result when viewing source was
blah
blah
I define 'CR', 'LF', 'CRLF' and use them as circumstances dictate.
the use of that definitely depends upon the circumstances; ill stick w/ the
predefined constant until i run into a problem ;)
-nathan