Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Newsletter {
- public function cadastrarEmail($email){
- if(!filter_var($email, FILTER_VALIDATE_EMAIL)):
- throw new Exception("Este email é invalido", 1);
- else:
- echo "Email cadastrado com sucesso!";
- endif;
- }
- }
- $newsletter = new Newsletter();
- try{
- $newsletter->cadastrarEmail("contato@acom");
- } catch(Exception $e){
- echo "Mensagem: ".$e->getMessage()."<br>";
- echo "Código: ".$e->getCode()."<br>";
- echo "Linha: ".$e->getLine()."<br>";
- echo "Arquivos: ".$e->getFile()."<br>";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement