<?php
class a
{
public $retorno;
public function test()
{
try {
throw new Exception('Error!');
} catch(Exception $e) {
$this->retorno = 'mensagem!';
}
}
public function response($e)
{
echo $this->retorno;
}
public function __destruct()
{
$this->response();
}
}
$a = new a;
$a->test();
Fatal error: Uncaught ArgumentCountError: Too few arguments to function a::response(), 0 passed in /in/a8LnB on line 23 and exactly 1 expected in /in/a8LnB:16
Stack trace:
#0 /in/a8LnB(23): a->response()
#1 [internal function]: a->__destruct()
#2 {main}
thrown in /in/a8LnB on line 16
Process exited with code 255.