Home > Article > Backend Development > How to set php post without parameters
php post parameter-free setting method: 1. Request the interface through ajax; 2. The client requests through curl; 3. Execute "file_get_contents("php://input");" on the PHP server.
The operating environment of this article: Windows 7 system, PHP 7.1 version, DELL G3 computer
No parameter name post data client and how to interface it Realized?
PHP version client:
1. The first case is that the client requests the interface through ajax.
$.ajax({ type: 'POST', url: url , data: data , success: success , dataType: dataType });
2. The second case is that the client can request through curl.
$ch = curl_init(); //设置URL,POST方式提交以及POST数据 curl_setopt($ch, CURLOPT_URL, $apiurl); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS, "post数据"); $result = curl_exec($ch);
PHP version server:
$sendjson=file_get_contents("php://input"); print_r($sendjson);
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to set php post without parameters. For more information, please follow other related articles on the PHP Chinese website!