3
I’m trying to create a class with a constructor
but it is returning me this error. I tried to do something similar to Java since I do not program in PHP
still, but is returning me this error:
Notice: Undefined variable: typegraph in C: Inetpub wwwroot HOPE php Graficos.php on line 23
I’ve tried the methods GETTERS
and SETTERS
and yet I couldn’t solve.
class Grafico{
private $typegraph=0;
private $graphTitle=0;
private $HorizontalTitle=0;
private $sufixo=0;
private $lineName=0;
private $valuesdescription=0;
private $values=0;
public function Grafico($typegraph_p, $graphTitle_p, $HorizontalTitle_p, $sufixo_p, $lineName_p, $valuesdescription_p, $values_p){
$typegraph = $typegraph_p;
$graphTitle = $graphTitle_p;
$HorizontalTitle = $HorizontalTitle_p;
$sufixo = $sufixo_p;
$lineName = $lineName_p;
$valuesdescription = $valuesdescription_p;
$values = $values_p;
}
public function Printa(){
echo $typegraph;
echo $graphTitle;
echo $HorizontalTitle;
echo $sufixo;
echo $lineName;
echo $valuesdescription;
echo $values;
}
}
To take class property, use
$this->nome_da_proriedade
and the printar method you can subistituir by__toString()
– Jeferson Assis