【发布时间】:2014-06-15 20:37:38
【问题描述】:
我阅读了this answer,但我相信有更好的方法可以在 Guzzle 中创建 http url 查询,我正在寻找类似的东西,但无法使其正常工作,也不知道是否有办法转储 url 字符串以查看它是否正确处理。有人可以告诉我正确的方法吗?
// works correctly
$client = New GuzzleHttp\Client();
$request = $client->get('http://192.168.50.8/foo?-db=database&-lay=layout&-find');
print_r($request->getBody());
不工作
$request = $client->get($config->Layout['server'], [], [
'query' => [
$config->Layout['switches'], // ([ '-db' => 'database', '-lay' => 'layout', '-find' => true)
$config->Layout['options'], // other params
]
]);
【问题讨论】:
-
请指定guzzle版本。如果是这样,我们可以给出具体的答案。
-
“不工作”是什么意思?哪个输入数据返回什么,你期望返回什么?