unexpected T_OBJECT_OPERATOR when trying to access atribute
Posted: Fri Jul 11, 2008 2:00 pm
I'm havin a very strange problem here. Even though I researched extensively I haven't not even close to understand what's happening.
I have two php files, one is a Class and the other a plain php file to create a object of this class which I'm going to call Demonstrator from now on. When I try to require(Class.cla) in the Demonstrator I get the following message:
This line is the first one on the code where I try to access a atribute:
Ideas anyone? I'm using PHP 5.x btw.
Oh, i'm posting the whole class code:
I have two php files, one is a Class and the other a plain php file to create a object of this class which I'm going to call Demonstrator from now on. When I try to require(Class.cla) in the Demonstrator I get the following message:
Code: Select all
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in ~/Class.cla on line 16This line is the first one on the code where I try to access a atribute:
Code: Select all
return this->$modelo;Oh, i'm posting the whole class code:
Code: Select all
<?PHP
class Carro {
private $modelo;
private $ano;
private $cor;
private $id;
public function __construct($vM, $vA, $vC, $vI) {
setModelo($vM);
setAno($vA);
setCor($vC);
setID($vID);
}
public function getModelo() {
return this->$modelo;
}
public function setModelo($vM) {
this->$modelo = $vM;
}
public function getAno() {
return this->$ano;
}
public function setAno($vA) {
this->$ano = $vA;
}
public function getCor() {
return this->$cor;
}
public function setCor($vC) {
this->$cor = $vC;
}
public function getID() {
return this->$id;
}
public function setModelo($vI) {
this->$id= $vI;
}
public function toString() {
return "Mod: " .this->getModelo(). "\nAno: " .this->getAno(). "\nCor: " .this->getCor(). "\n";
}
}
?>