Last active
October 18, 2016 13:37
-
-
Save airtonzanon/683d71af2efd46bd2c7d9bb07a5506ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'PessoaModel.php'; | |
// não há necessidade de passar os parâmetros por exemplo | |
$pessoa = new PessoaModel(); | |
// mas tu vai ter que setar os atributos um por um | |
$pessoa->setNome('Foo'); | |
$pessoa->setSexo('Masculino'); | |
$pessoa->setIdade(50); | |
print_r($pessoa->toArray()); | |
//Você também pode colocar os parâmetros na hora de instanciar | |
$pessoa = new PessoaModel('Foo', 'Masculino', 50); | |
print_r($pessoa->toArray()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Pessoa { | |
private $nome; | |
private $sexo; | |
private $idade; | |
public function __construct($nome = null, $sexo = null, $idade = null){ | |
$this->nome = $nome; | |
$this->sexo = $sexo; | |
$this->idade = $idade; | |
} | |
//getters e setters se necessario | |
//métodos | |
public function toArray(){ | |
return get_object_vars($this); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment