PHP 7.3新特性

1、json解析出错提醒
json_decode("{");
json_last_error() === JSON_ERROR_NONE // 这个返回false
json_last_error_msg() // 但是这里返回 "Syntax error"
php 7.3中针对这个问题进行了修复,增加了JSON_THROW_ON_ERROR
use JsonException;
try {
$json = json_encode("{", JSON_THROW_ON_ERROR);
return base64_encode($json);
} catch (JsonException $e) {
throw new EncryptException('Could not encrypt the...点击查看剩余70%
网友评论0