开发者

Array from Requests

Hi I've set up 2 scripts, both communicating back and forth.

One thing I'd like is for one script to post an unknown amount of GETs to the other script.

I'd like the other script to some how be able to grab all the GETS and put the v开发者_运维知识库alues in an array.


$_GET already is an array. No reason you can't just copy it into your another array whose name is easier to type.

$array = $_GET;


If you simply want to make GET requests from one script to another, put something like

file_get_contents( "http://www.yoursite.com/script_2.php?some_var=some_value" );

And then, in script_2.php just read the variable

$_GET['some_var'];


If I understand you correctly you want to post your some GET data received by script_1.php from script_1.php to script_2.php,right?If so ,this probably can help you

<?php
/*@file script_1.php*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'url_of_script_2.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_GET);
curl_exec($ch);
?>

And in script_2.php,you will get the GET datas by using $_POST.See curl in manual

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜