PHP check whether Incoming Request is JSON type

前端 未结 6 1088
轻奢々
轻奢々 2020-12-20 14:57

Is there anyway to check whether an incoming request is of AJAX JSON type?

I tried

if(($_SERVER[\'REQUEST_METHOD\']==\'JSON\'))
{
}

6条回答
  •  攒了一身酷
    2020-12-20 15:57

    You can do a check on the accept param, if it's text/javascript your talking json, if it's text/xml guess what :P

    $_SERVER['HTTP_ACCEPT']

提交回复
热议问题