0
点赞
收藏
分享

微信扫一扫

php判断字符串是否是json格式

    /**
     * 校验json字符串
     * @param string $stringData 
     * @return bool
     */
    function isJsonString($stringData)
    {
        if (empty($stringData)) return false;

        try
        {
            //校验json格式
            json_decode($stringData, true);
            return JSON_ERROR_NONE === json_last_error();
        }
        catch (\Exception $e)
        {
            return false;
        }
    }
举报

相关推荐

0 条评论