Created
September 24, 2012 17:50
-
-
Save geovanerocha/3777271 to your computer and use it in GitHub Desktop.
Class sample @ PHP.
This file contains hidden or 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 { | |
public $pais = 'Brasil'; | |
function andar($nome, $velocidade){ | |
echo $nome . ' está andando a ' . $velocidade . 'km/h'; | |
echo '</p>'; | |
echo 'País de origem: ' . $this->pais; | |
} | |
function falar($nome, $palavra){ | |
echo $nome . ' diz: ' . $palavra; | |
} | |
} | |
/* Instanciando um objeto e utilizando suas funções */ | |
$pessoa = new Pessoa(); | |
$pessoa->andar('Geovane',10); | |
echo '</p>'; | |
$pessoa->falar('Geovane','Olá mundo'); | |
/* | |
@ Saída: | |
@ Geovane está andando a 10km/h | |
@ País de origem: Brasil | |
@ Geovane diz: Olá mundo | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment