php - 打印对象未在 PHP 中触发错误
问题描述
根据我正在阅读的书,print
未实现的 ing 对象__toString()
应该会引发错误:
Object of class popp\ch04\batch22\Person could not be converted to string ...
当我尝试这样做时,我收到一条消息Process finished with exit code 255
,但没有描述性错误。我正在使用 PhpStorm。
<?php
class Person{}
$person = new Person();
try {
print $person;
} catch(Exception $e) {
print $e;
}
我应该启用一个开关来接收错误吗?
解决方案
您可以将 PHP 配置为自行生成错误,而不是手动向 PHP 运算符添加错误报告代码。
error_reporting
应始终设置为E_ALL
.
发展:
display_errors
应设置为1
。
生产:
display_errors
应设置为0
。
log_errors
应设置为1
。
阅读有关错误报告的更多信息。
推荐阅读
- php - Facebook 图表仅返回 id
- javascript - 升级全日历?
- flutter - 如何在 DataTable 小部件中滚动 DataRow 项目
- vue.js - 基于插件值的 Vue 计算属性
- regex - 正则表达式:匹配最后一个字符串,直到出现另一个字符串(如果出现)
- python - tf.data.Dataset.window 和 tf.train.SequenceExample
- php - 我想使用 Zend 框架 2 在同一表单上的 2 个不同路径上上传 2 个文件
- java - 方法 println(Object...) 的最后一个参数的类型 int[][] 与 vararg 参数类型不完全匹配
- libgdx - 在 libgdx 中正确实现平移和缩放
- r - Geom_density_2d_filled() ggplot:(1)如何围绕所有点绘制轮廓,(2)如何改变渐变颜色?