php如何从Angular post请求中获取值?
PHP
$data = $_GET['params'] or $_REQUEST['params'];
echo $data;
Angular
var params = {
"key":"value"
}
$http.get('php-page.php', {params:params})
.then(function(response){
var mydata = response.data;
return $scope.myresponse = mydata;
});
答案 0 :(得分:0)
在您的php文件中,使用以下代码从角度帖子值中获取帖子值。
$data = file_get_contents("php://input");
$objData = json_decode($data);
示例:
$userName = isset($objData->userName) ? $objData->userName : '';