내가 HTML 코드를 제공합니다에로 난 [] NUM을 사용하고이 curl.For 사용하여 입력으로 여러 번호를 보내려고하는 것은 내 코드컬을 사용하여 여러 개의 숫자를 입력으로 보내는 방법은 무엇입니까?
$num[]=$_POST["num"];
$msg=$_POST["msg"];
$url = 'http://localhost/s/a.php';
$fields = array(
'num'=>urlencode($_POST["num"]),
'msg'=>urlencode($_POST["msg"]));
$fields_string = http_build_query($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields);
$re = curl_exec($ch);
이지만 오류
Warning: urlencode() expects parameter 1 to be string, array given in
1.'$ _POST [ "NUM"]'또는'$ _POST [ "NUM"]'중 하나 또는 둘 다 배열입니다. 2. 왜'$ num [] = $ _POST [ "num"];'을하고 있습니까? $ num = $ _POST [ "num"];' –
3. 이것을 설정하지 않으면'$ re'에서 아무 것도 얻을 수 없습니다. curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true); 4.'CURLOPT_POST'는'count ($ fields)'처럼 정수를 취하지 않으며,'curl_setopt ($ ch, CURLOPT_POST, true); '이어야합니다. –
덕분에 해결했습니다. –