Swift-Daniel answers how PHP receives the number of headers in the iOS request

Source: Internet
Author: User
Alamofire.request (. POST, "Http://srxapp.zkkd.com/ios.php/Login/login", headers: ["token": Token]). Responsejson {(data) in

    let json = JSON(data: data.data!)    print(json)}php端怎么接受 headers 里面的 token值呢

Reply content:

Alamofire.request (. POST, "Http://srxapp.zkkd.com/ios.php/Login/login", headers: ["token": Token]). Responsejson {(data) in

    let json = JSON(data: data.data!)    print(json)}php端怎么接受 headers 里面的 token值呢

$_server[' Http_token ']

Getallheaders () [' token '];

getallheadersIs apache_request_headers the alias, can not be used for the nginx server, oneself simply write a function fetch.

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数组

All request data is placed in $_request.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.