3
警告:register_shutdown_function()來:無效關機回調當使用register_shutdown_function()時,爲什麼我的'shutdown callback'無效?
trait ErrorTrait {
public function shutDownFunction() {
$error = error_get_last();
// fatal error, E_ERROR === 1
if ($error['type'] === E_ERROR) {
//do your stuff
$messageStore="Using $this when not in object context";
if (strstr ($error['message'],$messageStore))
{
echo "found it";
}
}
}
public function shutdown_function()
{
register_shutdown_function('shutDownFunction');
}
}
我用這種特質在我的主類和調用的函數從它
use ErrorTrait;
public function test()
{ self::shutDownFunction();
self::shutdown_function(); }
然後在這一點上我在稱爲「運行」的函數中調用測試函數
我只需調用函數即可。
public function run()
{
self::test();
// Rest of code}
任何想法爲什麼這會導致問題?
謝謝你的工作 –