Giter Site home page Giter Site logo

heyuuu.github.io's Introduction

heyu.github.io

heyuuu.github.io's People

Contributors

heyuuu avatar

Watchers

 avatar

heyuuu.github.io's Issues

setGlobal之后, 某种情况下 $_POST 不正确

setGlobal之后,在有些情况下,$_POST不正确,但是$request->post是正常的。
例:

环境
php 5.6.18
swoole 1.8.2

swoole_http_server 的代码

$serv = new swoole_http_server('0.0.0.0', 9544);

$serv->on('Request', function($request, $response) {
    ob_start();
    var_dump($_POST);
    var_dump($request->post);
    $response->end(ob_get_clean());
});

$serv->setGlobal(HTTP_GLOBAL_ALL);
$serv->start();

CURL 请求代码

$ch  = curl_init();
$url = 'http://127.0.0.1:8080/';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, ['a' => 1]);
curl_exec($ch);

第一次请求$_POST为空数组,之后每次$_POST 为NULL,并报 Notice : Undefined variable: _POST
$request->post 一直为数组 ['a' => 1], 正常。

如果把请求curl的代码中

curl_setopt($ch, CURLOPT_POSTFIELDS, ['a' => 1]);

改为

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['a' => 1]));

$_POST 和 $request->post 就都正常了。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.