I'm new to php
and I have executed below code.
<?php
class my_class{
var $my_value = array();
function my_class ($value){
$this->my_value[] = $value;
}
function set_value ($value){
// Error occurred from here as Undefined variable: my_value
$this->$my_value = $value;
}
}
$a = new my_class ('a');
$a->my_value[] = 'b';
$a->set_value ('c');
$a->my_class('d');
foreach ($a->my_value as &$value) {
echo $value;
}
?>
I got below errors. What could be the error?
Notice: Undefined variable: my_value in C:\xampp\htdocs\MyTestPages\f.php on line 15
Fatal error: Cannot access empty property in C:\xampp\htdocs\MyTestPages\f.php on line 15
var
and a method with the same name as the class indicate a pretty old, outdated tutorial