Advertisement
Geicy

Untitled

Jul 30th, 2021
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. <?php
  2.  
  3. class Pessoa {
  4. public function atribuirNome($nome){
  5. return "O nome da pessoa é: ".$nome;
  6. }
  7. }
  8.  
  9. class Exibe {
  10. public $pessoa;
  11. public $nome;
  12.  
  13. 1
  14. 2
  15. 3
  16. 4
  17. 5
  18. 6
  19. 7
  20. 8
  21. function __construct($nome){
  22.     $this->pessoa = new Pessoa();
  23.     $this->nome = $nome;
  24. }
  25.  
  26. public function exibeNome(){
  27.     echo $this->pessoa->atribuirNome($this->nome);
  28. }
  29. }
  30.  
  31. $exibeNome = new Exibe("Igor");
  32. $exibeNome->exibeNome();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement