[英]Printing an values from a session array in PHP
I'm trying to print a list of values that I've stored in a session-variable array, and all I'm getting is that 'Headers already sent...' error. 我正在尝试打印存储在会话变量数组中的值的列表,而我得到的只是“ Headers has sent ...”错误。 On the error page I can see the array working, but obviously it won't proceed from there.
在错误页面上,我可以看到该数组正在工作,但显然不会从那里继续进行。 The line the error mentions is this:
错误提及的行是这样的:
$uploadedfiles = print_r($_SESSION['uploadedfiles']);
The array is declared and values are added to it with this: 声明数组,并使用以下方法将值添加到数组中:
array_push($_SESSION['uploadedfiles'], $file_name);
Any thoughts? 有什么想法吗?
Thanks kindly. 谢谢。
print_r()
will automatically print to the screen. print_r()
将自动打印到屏幕上。 You need to set the second parameter to true
to actually capture it in a variable. 您需要将第二个参数设置为
true
才能将其实际捕获到变量中。
$uploadedfiles = print_r($_SESSION['uploadedfiles'], true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.