Advertisement
ph4x35ccb

encapsulamento

Mar 12th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.30 KB | None | 0 0
  1. <?php
  2.  
  3. class Pessoa{
  4.     private $nome;
  5.  
  6.     function setNome($nome){
  7.         $this -> nome = $nome;
  8.     }
  9.     function getNome(){
  10.         return $this -> nome;
  11.     }
  12.    
  13. }
  14. $p1 = new Pessoa();//cria uma nova instancia
  15. $p1 -> setNome('Teste encapsulamento');// acesa a a função setNome e e atribui o nome
  16. var_dump($p1);
  17.  
  18. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement