相当于通过电子邮件发送数据的 var_dump
我一直在寻找一个 php 库,它允许我通过电子邮件发送变量的格式化数据(如 krumo)。
这是因为我创建了一个错误处理程序,用于发送包含生产环境数据的电子邮件。
I've been looking for a php library that allows me to send formatted data (like krumo) for variables via email.
This is because I've created an error handler that sends an email with the data on production environment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以
json_encode()
或serialize()
如果您希望数据是机器可读的。如果您希望它易于人类阅读,您可以将第二个参数
TRUE
提供给print_r()
以字符串形式返回数据,或使用 输出缓冲以捕获var_dump()
的输出成字符串。例如
You could
json_encode()
orserialize()
the data if you want it to be machine readable.If you want it to be human readable, you can either supply the second argument
TRUE
toprint_r()
to return the data as a string, or use output buffering to catch the output ofvar_dump()
into a string.e.g.
将发送 $obj 内容的人类可读版本。如果您需要类型/大小信息,可以使用 var_dump,但需要使用 ob 函数来捕获其输出,因为它没有“返回而不是输出”选项。
would send human-readable versions of $obj's contents. If you need type/sizing information, you can use var_dump, but will need to use the ob functions to capture its output, as it doesn't have a 'return instead of outputting' option.
我将使用
json_encode()
并将变量作为 JSON 字符串在电子邮件中发送。I would use
json_encode()
and send variables as a JSON string in the email.另一种方式可以将其作为 HTML 发送
例如
但请确保将电子邮件内容的标题设置为
another way you can send it as HTML
For example
But make sure to set the headers of the email content to