li {font-size: 16px;} li.fail {color:red} li.success {color: green} li label{ display:inline-block; width: 15em}';
echo '
执行环境检测
';
function success($title) {
print_r("[成功]");
}
function fail($title, $description) {
print_r("[失败] {$description}");
}
if(preg_match("/^\d+\.\d+/", PHP_VERSION, $matches)) {
$version = $matches[0];
if($version >= 5.4) {
success("PHP $version");
} else {
fail("PHP $version", "需要PHP>=5.4版本");
exit(1);
}
}
try {
set_error_handler(function () { throw new Exception(); });
date_default_timezone_get();
restore_error_handler();
} catch(Exception $e) {
fail('默认时区设置', '请设置默认时区,如:date_default_timezone_set("Asia/Shanghai")');
}
echo '依赖扩展检测,如失败请安装相应扩展
';
$dependencies = array (
'json_encode' => null,
'curl_init' => null,
'hash_hmac' => null,
'simplexml_load_string' => '如果是php7.x + ubuntu环境,请确认php7.x-libxml是否安装,x为子版本号',
);
foreach($dependencies as $funcName => $description) {
if(!function_exists($funcName)) {
fail($funcName, $description || '');
} else {
success($funcName);
}
}