dpgjci27392 2009-11-28 22:29
浏览 39
已采纳

如何将数组加变量传递给PHP中的函数?

I have a function prototype as such:

function do_upload( $file, $id, $type )

And I'm calling the function like this:

$this->do_upload( $files, $id, 'article' );

However, only $files is actually being passed through to the function. I'm sure it's simple but what have I done wrong?

EDIT:

So $file is just an array of file information, similar to $_FILES and it is passed through fine, I do some manipulation of it further in the function.

$id is set before I call the function, if I print_r() before the function call I see an ID I would expect and $type is just a string.

However, If I print_r() or die() on either $id or $type they are both blank and var_dump() returns the following:

die( var_dump( $id ) ); -> string(0) ""
die( var_dump( $type ); -> bool(false)

Right before the function call: die( var_dump( $id) ); -> string(3) "111"

Any ideas?

SOLUTION:

In case anyone has a similar problem, check the accepted answer below. Essentially I needed to pass the $files array by reference as it was using up the available stack space.

Thanks

  • 写回答

5条回答 默认 最新

  • dongpengqin3898 2009-11-29 11:31
    关注

    I think your actually running out of stack space (or whatever space php uses internally for call stacks) for the function call. Try passing $files by reference. Equally try passing just a string to $files and see if that brings the other parameters back.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?