GET 500 (internal error) PHP

1

Good morning,

I wrote a PHP class

<?php 

private $v;
private $v2;
private $v3;

public function __construct(){
    printf("Objeto criado com sucesso!");
}

public function setValor(){
    $this->$v = "valor";
    $this->$v2 = "valor2";
    $this->$v3 = "valor3";
}

public function getValor1(){
    return $this->$v;
}

public function getValor2(){
    return $this->$v2;
}

public function getValor3(){
    return $this->$v3;
}
}
$t = new Teste();
$t->setValor();
?>

But I can not access the serValor () method, I always get the GET 500 (Internal Server Error) error, however I do not see anything wrong with the code, can anyone help?

    
asked by anonymous 25.03.2017 / 15:49

1 answer

2

When accessing variables, you no longer need to use the $ sign.

public function setValor(){
    $this->v = "valor";
    $this->v2 = "valor2";
    $this->v3 = "valor3";
}
    
25.03.2017 / 15:56