Of course, the method itself can assign explicit values to properties.
public function reset()
{
$this->someString = "original";
$this->someInteger = 0;
}
$ this-> SetInitialState () from constructor
, , . .
<?php
class MyClass {
private $var;
function __construct() { $this->setInitialState(); }
function setInitialState() { $this->var = "Hello World"; }
function changeVar($val) { $this->var = $val; }
function showVar() { print $this->var; }
}
$myObj = new MyClass();
$myObj->showVar();
$myObj->changeVar("New Value");
$myObj->showVar();
$myObj->setInitialState();
$myObj->showVar();
?>