将数组的内容写入另一个文件?
我正在尝试测试 PayPal IPN,因此我想设置一个脚本将 $_GET
数组的所有内容写入文件,以便我可以查看所请求的内容是否为正如我所假设的。
但是,我在配置文件以实际显示数组的内容时遇到问题,就像它被转储一样。
例如:
$string = $_GET;
$fp = fopen("paypal_req.txt", "w");
fwrite($fp, $string);
fclose($fp);
只需将 $_GET
的值回显到文件 paypal_req.txt
中,当然该文件是 Array
。
如何将数组 $_GET
的内容转储到 paypal_req.txt
中,就像使用 var_dump()
一样?
任何帮助将不胜感激!
I'm attempting to test out the PayPal IPN, so I want to set-up a script to write all the contents of the $_GET
array to a file, so I can see if what is requested is as I assume.
However, I'm having trouble configuring the file to actually display the contents of the array as though it were being dumped.
For example:
$string = $_GET;
$fp = fopen("paypal_req.txt", "w");
fwrite($fp, $string);
fclose($fp);
Simply echo's the value of $_GET
into the file paypal_req.txt
, which of course is Array
.
How could I have the contents of the array $_GET
dumped into paypal_req.txt
as though I were using var_dump()
?
Any help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想要与 var_dump() 类似的输出,可以使用 var_export() 函数:
If you want a similar output to var_dump(), you can use the var_export() function:
var_export($_GET, true)
建议是最好的,但是您可以通过输出缓冲捕获其输出来使用 var_dump。The
var_export($_GET, true)
suggestion is the best, but you could use var_dump by capturing its output with output buffering.