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
--- php5-200408112030/main/main.c 2004-07-25 04:30:49.000000000 -0400 +++ php5-200408112030-new/main/main.c 2004-08-11 23:25:34.000000000 -0400 @@ -1430,6 +1430,7 @@ REGISTER_MAIN_STRINGL_CONSTANT("PHP_CONFIG_FILE_PATH", PHP_CONFIG_FILE_PATH, sizeof(PHP_CONFIG_FILE_PATH)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_CONFIG_FILE_SCAN_DIR", PHP_CONFIG_FILE_SCAN_DIR, sizeof(PHP_CONFIG_FILE_SCAN_DIR)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_SHLIB_SUFFIX", PHP_SHLIB_SUFFIX, sizeof(PHP_SHLIB_SUFFIX)-1, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("PHP_EOL", PHP_EOL, sizeof(PHP_EOL)-1, CONST_PERSISTENT | CONST_CS); php_output_register_constants(TSRMLS_C); php_rfc1867_register_constants(TSRMLS_C);
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php