mvsp

index_aula3.php

Jul 21st, 2021
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2.  
  3. class Login{
  4.     private $email;
  5.     private $senha;
  6.  
  7.     public function getEmail(){
  8.         return $this->email;
  9.     }
  10.  
  11.     public function getSenha(){
  12.         return $this->senha;
  13.     }
  14.  
  15.     public function setEmail($e){
  16.         $email = filter_var($e,FILTER_SANITIZE_EMAIL);
  17.         $this->email = $email;
  18.     }
  19.  
  20.     public function setSenha($e){
  21.         $this->senha = $e;
  22.     }
  23.  
  24.     public function Logar() {
  25.         if($this->email == "teste@teste.com" and $this->senha == "123456"):
  26.             echo "Logado com sucesso!";
  27.         else:
  28.             echo "Dados inválidos";
  29.         endif;
  30.     }
  31. }
  32.  
  33. $logar = new Login();
  34. $logar->setEmail("teste@teste.com");
  35. $logar->setSenha("123456");
  36. $logar->Logar();
  37.  
  38. echo "<br>";
  39. echo $logar->getEmail()."<br>". $logar->getSenha();
  40.  
Add Comment
Please, Sign In to add comment