当前位置:Gxlcms > PHP教程 > php形成json语句,多出前面一句,怎么去掉!

php形成json语句,多出前面一句,怎么去掉!

时间:2021-07-01 10:21:17 帮助过:5人阅读

php源码
$row['usrtype'],'sessionid'=>$usrname,'usrnm'=>$row['usrnm'],'usrid'=>$row['usrid']);										echo json_encode($jsonArr);										break;					}					else{						echo '{"logintype":"-1"}';						}				}			}				}?>



浏览器解析为
{"logintype":"0","sessionid":"0","usrnm":"mjc","usrid":"0"}



怎么将前一行去掉!


回复讨论(解决方案)

把相关程序文件转存为无bom的utf8文件就OK了。
方法最好用新建无bom文件,把代码复制过去,再保存。

php页面里去掉这句不就行了

json输出前加入

header('Content-type: application/json');

试试~

php页面里去掉这句不就行了



你找个地方去掉,我这个就没那个输出,估计是默认的,

include "./mobile/sql.php"; 这个里的吧

估计是 include "./mobile/sql.php"; 文件生成的吧,贴出来看看。

从来没有遇到过这样的奇葩问题了,呵呵

header("Content-type:application/json;charset=utf-8")

你肯定有include的页面里加这句了

咋去掉的啊 我也出现这种情况了
HTTP/1.1 200 OK
Date: Fri, 18 Apr 2014 09:00:59 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Content-Length: 2352
Cache-Control: private
Content-Type: application/json; charset=utf-8

{"body":{"item":[{"BuyPriceoff":0,"BuyTime":"未确定","CityId":420100,"CityName":"武汉","Content":"白色的年前提车","CountyId":420105,"CountyName":"汉阳","CreateTime":"2014-02-06 11:35:27","DealerId":11569,"HandleTime":"2014-01-07 11:35:28","Id":23010786,"Name":"张国雄","OrderType":0,"Phone":"18108624658","ProvinceId":420000,"ProvinceName":"湖北","ReDealerId":11569,"SeriesId":2945,"SeriesName":"雪铁龙C4L","SpecId":15737,"SpecName":"雪铁龙C4L 2013款 1.8L 手动劲智版","State":1},{"BuyPriceoff":0,"BuyTime":"","CityId":140100,"CityName":"太原","Content":"","CountyId":140105,"CountyName":"小店","CreateTime":"2014-02-06 11:34:35","DealerId":6752,"HandleTime":"2014-01-07 11:34:36","Id":23010726,"Name":"栗","OrderType":1,"Phone":"15386885719","ProvinceId":140000,"ProvinceName":"山西","ReDealerId":6752,"SeriesId":792,"SeriesName":"雪铁龙C5","SpecId":17043,"SpecName":"雪铁龙C5 2013款 2.0L 自动悦享型","State":1},{"BuyPriceoff":0,"BuyTime":"","CityId":440300,"CityName":"深圳","Content":"","CountyId":0,"CountyName":"","CreateTime":"2014-01-07 11:34:30","DealerId":75882,"HandleTime":"","Id":23010715,"Name":"黎","OrderType":0,"Phone":"18320819196","ProvinceId":440000,"ProvinceName":"广东","ReDealerId":0,"SeriesId":2945,"SeriesName":"雪铁龙C4L","SpecId":17658,"SpecName":"雪铁龙C4L 2014款 1.8L 自动智驱版劲智型 ","State":0},{"BuyPriceoff":0,"BuyTime":"","CityId":320300,"CityName":"徐州","Content":"","CountyId":0,"CountyName":"","CreateTime":"2014-01-07 11:34:04","DealerId":5248,"HandleTime":"","Id":23010688,"Name":"吴","OrderType":0,"Phone":"13852043028","ProvinceId":320000,"ProvinceName":"江苏","ReDealerId":0,"SeriesId":2945,"SeriesName":"雪铁龙C4L","SpecId":15739,"SpecName":"雪铁龙C4L 2013款 1.8L 自动劲驰版","State":0},{"BuyPriceoff":0,"BuyTime":"","CityId":440300,"CityName":"深圳","Content":"铂金灰","CountyId":0,"CountyName":"","CreateTime":"2014-02-06 11:33:39","DealerId":9802,"HandleTime":"2014-01-07 11:33:40","Id":23010669,"Name":"潘","OrderType":0,"Phone":"13923846836","ProvinceId":440000,"ProvinceName":"广东","ReDealerId":9802,"SeriesId":2945,"SeriesName":"雪铁龙C4L","SpecId":14551,"SpecName":"雪铁龙C4L 2013款 1.6L 手动劲智版","State":1}],"pages":40337,"total":201683},"cache":1000,"message":"","success":1,"result":0}NULL

人气教程排行