-3
What is the solution to the error below?
public function __toString(){
return json_encode(array(
"idusuario" =>$this->getIdusuario(),
"deslogin" =>$this->getDeslogin(),
"dessenha" =>$this->getDessenha(),
"tdcadastro" =>$this->getDtcadastro()->format("d/m/Y - H: i: s")
));
}
This is the mistake:
Fatal error: Method Usuario::__toString() must not throw an Exception, Caught Error: Call to a Member Function format() on null in
The error is not in the method
__toString
. What instancegetDtcadastro
returns? If possible put the code too.– Papa Charlie
Apparently you have one
new throw execption()
or some instruction has launched an Exception there– rray
It seems that your registration date is null and the format method cannot format your date from null.
– Antonio Alexandre