I have some difficulties in instantiating objects in php.
I have the code in OO:
class Usuario {
private $idade;
private $nome;
public function getNome() {
return $this->nome;
}
public function setNome($nome) {
$this->nome=$nome;
}
public function getIdade() {
return $this->idade;
}
public function setIdade($idade) {
$this->idade=$idade;
}
}
And the test class:
include("Usuario.php");
classe TesteUsuario {
$usuario1 = TesteUsuario();
$usuario2 = New Usuario();
}
Instantiating the object within the scope of the class, gives the error:
(!) Parse error: syntax error, unexpected 'TestUser' (T_STRING) in C: \ wamp \ www \ lists \ TestUser.php on line 4>
If instantiating outside also gives error.
How do I? I have already realized that I can use the test file without class, ie:
include("Usuario.php");
$usuario2 = New Usuario();