📜  php 接收获取 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:51.175000             🧑  作者: Mango

代码示例1
// Send data trough e.g. AJAX in JavaScript

$.ajax({
    type: "GET",
    url: 'example.php',
    data: { "num1": 1, "num2": 2},
    contentType: "application/json; charset=utf-8",
    dataType: "JSON",
    async: false
})

// You would receive it like this:
  
$num1 = $_GET["num1"];
$num2 = $_GET["num2"];

$sum = $num1 + $num2;
echo $sum;

// Would output: 3