Einstellung public class Variablen

Wie richte ich eine öffentliche variable. Ist das richtig?:

class Testclass
{
  public $testvar = "default value";

  function dosomething()
  {
    echo $this->testvar;
  }
}

$Testclass = new Testclass();
$Testclass->testvar = "another value";    
$Testclass->dosomething();
Dein Weg ist in Ordnung

InformationsquelleAutor Cudos | 2009-12-30

Schreibe einen Kommentar