alamofire.request(.post, "http://srxapp.zkkd.com/ios.php/login/login", headers: ["token":token]).responsejson { (data) in
<code> let json = JSON(data: data.data!)
print(json)
}
php端怎么接受 headers 里面的 token值呢</code>alamofire.request(.post, "http://srxapp.zkkd.com/ios.php/login/login", headers: ["token":token]).responsejson { (data) in
<code> let json = JSON(data: data.data!)
print(json)
}
php端怎么接受 headers 里面的 token值呢</code>
$_SERVER['HTTP_TOKEN']
getallheaders()['token'];
getallheaders 是 apache_request_headers 的别名,不能用于 nginx 服务器,自己简单写一个function 获取。
立即学习“PHP免费学习笔记(深入)”;
<code>function request_header($key = null)
{
$all_headers = [];
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
$all_headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return is_null($key) ? $all_headers : (isset($all_headers[$key]) ? $all_headers[$key] : null);
}
request_header('token'); // 不传key返回所有heads数组</code>
所有请求数据都在$_REQUEST中放的
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号