作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有方法,在这个方法中可能会发生 fatal error ,为了捕获这个错误我做了这个
class a {
function shutDownFunction() {
$error = error_get_last();
if ($error['type'] == 1) {
echo "this is fatal error";
}
}
function terribleFunction () {
register_shutdown_function(array($this,'shutdownFunction'));
// here is code, wich may causes fatal error
}
}
好的,这个明白了,但是我需要将参数从 terribleFunction
传递给 shutDownFunction
。怎么做这个?
最佳答案
首先您需要指定 shutDownFunction
应该接受一个参数。
函数 shutDownFunction($var)
然后你可以这样调用register_shutdown_function
register_shutdown_function(array($this, 'shutdownFunction'), $myVar);
文档是 here评论里有例子。
关于php - 如何将参数传递给专门用于 register_shutdown_function 的可调用方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13703065/
我有一个带有模板函数的基类,该函数具有通用模板类型和专用版本。 #ifndef BASE_CLASS #define BASE_CLASS #include using namespace std;
我有这个 3D vector 模板 template class Vec3TYPE{ public: union{ struct{ TYPE x,y,z; }; struct{ TY
我是一名优秀的程序员,十分优秀!