Home > Backend Development > PHP Problem > How to set php post without parameters

How to set php post without parameters

藏色散人
Release: 2023-03-10 10:18:01
Original
2090 people have browsed it

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.

How to set php post without parameters

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
});
Copy after login

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);
Copy after login

PHP version server:

 $sendjson=file_get_contents("php://input");
 print_r($sendjson);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template