【发布时间】:2014-03-28 18:56:46
【问题描述】:
我目前正在使用 sitl/curl-easy 来制作多卷曲并行请求,但我在范围/状态方面遇到了一些困难:
// Init queue of requests
$queue = new \cURL\RequestsQueue;
...初始化队列选项
// Set function to be executed when request will be completed
$queue->addListener('complete', function (\cURL\Event $event)
{
$response = $event->response->getContent();
// ugly :D, get the key from the object request
$key = explode("&key=", array_values($event->request->getOptions()->toArray())[0])[1];
// if response is not null, truncate it to use less space
if ($response != null){
$response = str_replace(array("\r", "\n"), "", $response);
}
>>>>>>>> DON'T WORK, $banner_holder is declared on the top of the php page
array_push($banner_holder, array("key"=> $key,"content"=>$response));
});
如何将 $key 和 $response 的数组推送到监听器之外?
提前致谢。
【问题讨论】:
标签: php scope listener mediator