Re: Newline

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/30/07, Crayon Shin Chan <crayon.shin.chan.uk@xxxxxxxxx> 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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux