0
I’m learning programming and came across the Try catch, however my code never enters the catch..
<?php
class NewsLetter{
public function cadastrarEmail($email){
if(!filter_var($email,FILTER_VALIDATE_EMAIL)):
throw new Exception("Este email é invalido",1);
else:
echo"ok";
endif;
}
}
$Newsletter = new NewsLetter();
try{
$Newsletter->cadastrarEmail("@haha");
} catch(Expection $e){
echo"aaaaaaaaaaa";
echo"Erro: ".$e->getCode();
}
?>