PHP json_decode is null error error code parsing JSON correct solution of 4 pages

In such cases, there is usually BOM head string parsing of 65279 lead, this time as long as the removal of BOM head on the line, wrote a simple analytical method BOM head.

public static function checkBOM(&$str)
    {
        if (ord(substr($str, 0, 1)) == 239 && ord(substr($str, 1, 1)) == 187 && ord(substr($str, 2, 1)) == 191) {
            $str = substr($str, 3);
            return true;
        }
        return false;
    }

 

Published 27 original articles · won praise 53 · views 160 000 +

Guess you like

Origin blog.csdn.net/auspi12341/article/details/89357135