【发布时间】:2012-03-23 12:41:41
【问题描述】:
在我们的一个网络应用程序中,用户可以选择首选语言,因此我们需要为每个用户动态设置区域设置。基本上:
function i18n_date($format, $date, $locale) {
setlocale(LC_TIME, $locale);
return strftime($format, $date);
}
问题是每隔一个页面加载,区域设置就会更改为默认值,在setlocale() 和strftime() 之间。根据the PHP docs,这应该来自“Windows 上的 IIS 或 Apache 等多线程服务器 API”,但我们的服务器 Apache 构建是非线程的:
Server version: Apache/2.2.17 (Ubuntu)
Server built: Nov 3 2011 02:13:53
Server's Module Magic Number: 20051115:25
Server loaded: APR 1.4.2, APR-Util 1.3.9
Compiled using: APR 1.4.2, APR-Util 1.3.9
Architecture: 64-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/apache2"
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="mime.types"
-D SERVER_CONFIG_FILE="apache2.conf"
那么为什么会这样呢?
【问题讨论】: