DOM头惹的祸

解析json 返回 JSON_ERROR_SYNTAX,api端返回正常

<?php

// $result 为 null
$result = json_decode($json);

// 返回 JSON_ERROR_SYNTAX
$reason = json_last_error();

经过查找原始阿里文件服务的php 带有DOM导致解析失败,下面是一个查找dom头的命令

find -type f | while read file;do [ "`head -c3 -- "$file"`" == $'\xef\xbb\xbf' ] && echo "found BOM in: $file";done
comments powered by Disqus
Table of Contents