Don't use `PHP_EOL` for textarea of form to array, use it:
array_values(array_filter(explode("\n", str_replace("\r", '', $_POST['data']))))
这些常量在 PHP 的内核中定义。它包含 PHP、Zend 引擎和 SAPI 模块。
PHP_VERSION
(string)
PHP_MAJOR_VERSION
(integer)
PHP_MINOR_VERSION
(integer)
PHP_RELEASE_VERSION
(integer)
PHP_VERSION_ID
(integer)
PHP_EXTRA_VERSION
(string)
PHP_ZTS
(integer)
PHP_DEBUG
(integer)
PHP_MAXPATHLEN
(integer)
PHP_OS
(string)
PHP_OS_FAMILY
(string)
PHP_SAPI
(string)
PHP_EOL
(string)
PHP_INT_MAX
(integer)
PHP_INT_MIN
(integer)
PHP_INT_SIZE
(integer)
PHP_FLOAT_DIG
(integer)
PHP_FLOAT_EPSILON
(float)
PHP_FLOAT_MIN
(float)
PHP_FLOAT_MAX
(float)
DEFAULT_INCLUDE_PATH
(string)
PEAR_INSTALL_DIR
(string)
PEAR_EXTENSION_DIR
(string)
PHP_EXTENSION_DIR
(string)
PHP_PREFIX
(string)
PHP_BINDIR
(string)
PHP_BINARY
(string)
PHP_MANDIR
(string)
PHP_LIBDIR
(string)
PHP_DATADIR
(string)
PHP_SYSCONFDIR
(string)
PHP_LOCALSTATEDIR
(string)
PHP_CONFIG_FILE_PATH
(string)
PHP_CONFIG_FILE_SCAN_DIR
(string)
PHP_SHLIB_SUFFIX
(string)
PHP_FD_SETSIZE
(string)
E_ERROR
(integer)
E_WARNING
(integer)
E_PARSE
(integer)
E_NOTICE
(integer)
E_CORE_ERROR
(integer)
E_CORE_WARNING
(integer)
E_COMPILE_ERROR
(integer)
E_COMPILE_WARNING
(integer)
E_USER_ERROR
(integer)
E_USER_WARNING
(integer)
E_USER_NOTICE
(integer)
E_RECOVERABLE_ERROR
(integer)
E_DEPRECATED
(integer)
E_USER_DEPRECATED
(integer)
E_ALL
(integer)
E_STRICT
(integer)
__COMPILER_HALT_OFFSET__
(integer)
TRUE
(boolean)
FALSE
(boolean)
NULL
(null)
参见魔术常量。
所有在核心扩展 的常量是 PHP 默认定义的。
Don't use `PHP_EOL` for textarea of form to array, use it:
array_values(array_filter(explode("\n", str_replace("\r", '', $_POST['data']))))
PHP_EOL can be used like that:
<?php
$data = 'some data'.PHP_EOL;
$fp = fopen('somefile', 'a');
fwrite($fp, $data);
?>
Which is the same of \r\n or \n depending on the OS.
You can put those lines in a while for example, and create a log file.
Volker's getOS() function needs to have the order of cases changed in the switch statement since "darwin" contains "win", which means that both "windows" and "darwin" will return self::OS_WIN. I've moved the 'dar' case above the 'win' case:
<?php
class System {
const OS_UNKNOWN = 1;
const OS_WIN = 2;
const OS_LINUX = 3;
const OS_OSX = 4;
/**
* @return int
*/
static public function getOS() {
switch (true) {
case stristr(PHP_OS, 'DAR'): return self::OS_OSX;
case stristr(PHP_OS, 'WIN'): return self::OS_WIN;
case stristr(PHP_OS, 'LINUX'): return self::OS_LINUX;
default : return self::OS_UNKNOWN;
}
}
}
?>