Please consider this class, I have an html page with two forms, first i submit form1
and after that I submit second one. I change $aaa
value in first function but after submitting second form, it show empty array and lost assigned value in func1
.
I want to access func1
assigned value in func2
.
class Myclass
{
private $aaa = array();
public function func1() {
$this->aaa= [1, 2, 3];
}
public function func2() {
var_dump($this->aaa);
}
}
In the HTML file:
<form action=" FUNC1 " method="post" id="form1">
<button type="submit">FUNC1</button>
</form>
<form action=" FUNC2 " method="post" id="form2">
<button type="submit">FUNC2</button>
</form>