值得注意的是,除非您捕捉从构造函数抛出的异常,否则,如果php脚本未能连接到数据库,它将终止。
It's worth noting that, unless you catch exceptions that are thrown from the constructor, your PHP script will terminate if it could not connect to the database.
类型构造函数的另一个独特行为是运行库管理类型构造函数中的异常的方式。
Another behavior unique to type constructors is how the runtime manages exceptions in a type constructor.
为了解决这一问题,可以在抛出异常语句期间,在异常对象的构造函数中生成一个堆栈跟踪。
To deal with this, you can generate a stack trace in the constructor of the exception object during the throw exception statement.
应用推荐