您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
webman-请求-获取服务端ip、服务端端口、判断是否ajax
发布时间:2022-01-18 22:18:24编辑:雪饮阅读()
实现如:
public function hello(Request $request)
{
$arr["getLocalIp"]=$request->getLocalIp();
$arr["getLocalPort"]=$request->getLocalPort();
//这个判断isAjax有点问题,是根据header头中有X-Requested-With字段并且值为XMLHttpRequest来判断的
//像是直接用jquery的ajax貌似就是获取的为false了
$arr["isAjax"]=$request->isAjax();
return response(var_export($arr,true));
}
关键字词:webman,ip,端口,ajax,獲取,判斷