Answer the question
In order to leave comments, you need to log in
How to solve problem with oop setter?
class sys{
public $log = "<br />";
static function log($newval)
{$this->log.=$newval."<br />";}
static function getlog()
{ return $this->log . "<br />";}
}
sys::log("установка");
sys::getlog();
Answer the question
In order to leave comments, you need to log in
As far as I understand, static functions don't instantiate an object, so they can't have $this
I could be very wrong
Ideas should be
class sys{
public $log = "<br />";
public function log($newval)
{$this->log.=$newval."<br />";}
public function getlog()
{ return $this->log . "<br />";}
}
$sys = new sys;
$sys->log("установка");
$sys->getlog();
var_dump($sys);
In principle, the answer has already been given above, but if you do not want to reinvent the wheel by creating a logger, then look at Monolog. It is considered the most popular logging library.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question