Advertisement
lsmn

retorno de função

Mar 30th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2.  
  3. class Teste
  4. {
  5.    private $nome;
  6.    
  7.    public function add($nome) {
  8.       return $this->nome = $nome;
  9.    }
  10.  
  11.    public function exec() {
  12.       $this->data($this->add($this->nome));
  13.    }
  14.  
  15.    private function data($funcao) {
  16.       $dados[] = $funcao;
  17.       foreach($dados as $dado) {
  18.          echo $dado;
  19.       }
  20.    }
  21. }
  22.  
  23.  
  24. $teste = new Teste;
  25.  
  26. $teste->add("pereira");
  27. $teste->add("souza");
  28. $teste->add("silva");
  29.  
  30. $teste->exec();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement