mvsp

aula 4.php

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