i try to build stack in PHP, but its didnt work. why?
this is the problem that i see:
Warning: Missing argument 1 for object::object(), called in C:\Program Files (x86)\EasyPHP-12.1\www\tb\index.php on line 152 and defined in C:\Program Files (x86)\EasyPHP-12.1\www\tb\index.php on line 126
Notice: Undefined variable: txt in C:\Program Files (x86)\EasyPHP-12.1\www\tb\index.php on line 127
Fatal error: Call to undefined function back() in C:\Program Files (x86)\EasyPHP-12.1\www\tb\index.php on line 146
this is the code: (i wrote in the code the lines of the problem with // )
class object {
private $obj;
private $next = null;
private $back = null;
public function object($txt) { // line 126
$this->obj = $txt; // line 127
}
public function back($back) {
$this->back = $back;
}
public function next($next) {
$this->next = $next;
}
}
class stack2 extends object {
private $arr;
private $head = -1;
private $tail = 0;
public function push($txt) {
$this->head++;
$arr[$this->head] = new object($txt);
if ($this->head-1 >= $this->tail) {
$arr[$this->head].back($this->head-1); // line 146
$arr[$this->head-1].next($this->head);
}
}
}
$s = new stack2(); // line 152
$s->push(11111);
$s->push(22222);