PHP FAQ
Timezone
- 默认使用 TZ 环境变量
<?php
date_default_timezone_set('Asia/Shanghai');
$script_tz = date_default_timezone_get();
if (strcmp($script_tz, ini_get('date.timezone'))){
echo '时区与INI配置 不同';
} else {
echo '时区与INI配置 相同'
}
php.ini
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
; https://www.php.net/manual/en/timezones.asia.php
date.timezone = "Asia/Shanghai"
redis session
/etc/php5/fpm/php.ini
session.save_handler = redis
# key 格式
# PHPREDIS_SESSION:j9rsgtde6st2rqb6lu5u6f4h83
session.save_path = "tcp://10.10.1.1:6379?auth=yourverycomplexpasswordhere"
强制类型
<?
declare(strict_types=1)
- strict_types
- 不允许 弱类型 类型转换
Connection to `ssl://pecl.php.net:443' failed: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP
apk add php7-openssl
sodium_crypto_aead_aes256gcm_decrypt
apk add php7-sodium
- sodium_crypto_aead_aes256gcm_is_available()