this is the way, but i would suggest to write a getter and setter for that variable.
class Testclass
{
private $testvar = "default value";
public function setTestvar($testvar) {
$this->testvar = $testvar;
}
public function getTestvar() {
return $this->testvar;
}
function dosomething()
{
echo $this->getTestvar();
}
}
$Testclass = new Testclass();
$Testclass->setTestvar("another value");
$Testclass->dosomething();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…