ds355020
2010-04-21 19:44
浏览 253
已采纳

如何在PHP中将多维数组作为GET参数传递?

I have the following code.

$connect  = new Connection ();
$response = $connect->putFile($fileName, $destination);
header("Location: /test.php?response=" . $response);

When I invoke header with the response, the file will stop execution, but I will have no error in the console... I am thinking maybe this array needs to be encoded for the url?

if that is the case how?

Thank you

图片转代码服务由CSDN问答提供 功能建议

我有以下代码。

  $ connect = new Connection(); 
 $ response = $ connect-> putFile($ fileName,$ destination); 
header(“Location:/ test。  php?response =“。$ response); 
   
 
 

当我用响应调用标头时,文件将停止执行,但我在控制台中没有错误 ...我想也许这个数组需要为url编码?

如果是这样的话?

谢谢

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • drjyvoi734793 2010-04-21 19:49
    已采纳

    If $response is a multi-dimensional array, you may fare best by serialize()ing it and urlencode() ing the result. It adds some overhead but not too much.

    However, transporting data through GET is seriously limited. The amount of data should not exceed 1-2 kilobytes. Source: For example here

    If your data is likely to exceed that limit, you should think about either transporting the data through POST or, if that's not possible, in a session or other kind of persistent storage.

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • duanjiang7505 2010-04-21 19:48

    Use http_build_query()

    http://us.php.net/http-build-query

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题