PHP check whether Incoming Request is JSON type

前端 未结 6 1090
轻奢々
轻奢々 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 16:01

    you can always set an extra header specifying that, or use an arbitrary variable to indicate JSON requests.

提交回复
热议问题