Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class pessoa{
- public $nome;
- function scr_nome($nom) {
- $this -> $nome = $nom;
- }
- function ver_nome(){
- return $this -> $nome;
- }
- }
- $mulher = new pessoa();
- $mulher -> scr_nome("Maria Paula");
- echo $mulher -> ver_nome();
- ?>
- <?php
- class pessoa{
- private $nome; // importante isso ser uma variável privada da classe já que tem um método de acesso a ela
- function setNome($nom) {
- $this->nome = $nom; // Aqui voce colocou o cifrão, isso retira a propriedade
- }
- function getNome(){
- return $this->$nome;
- }
- }
- $mulher = new pessoa();
- $mulher->setNome("Maria Paula");
- echo $mulher->getNome();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement