Simple PHP class -
i learning php
, created below class, can't seem figure out why giving me below errors says:
144
warning: missing argument 1 setters::set_a(), called in c:\xampp\htdocs\php\accessmod2.php on line 19 , defined in c:\xampp\htdocs\php\accessmod2.php on line 9
notice: undefined variable: value in c:\xampp\htdocs\php\accessmod2.php on line 11
<?php class setters{ private $a = 144; public function get_a(){ return $this->a; } public function set_a($value){ $this->a = $value; } } $example = new setters(); echo $example->get_a()."<br />"; $example->set_a(15)."<br />"; echo $example->set_a()."<br />"; ?>
you have use parameter set()
function. in case, think want see if set()
function have work. use get()
function.
so change :
echo $example->get_a()."<br />"; $example->set_a(15)."<br />"; echo $example->get_a()."<br />";
and result :
144 15
Comments
Post a Comment