<?PHPclassnode{Private $value; Private $next; Public function__construct ($value=0,$next=NULL){ $this->value=$value; $this-Next=$next; } Public functionGetValue () {return $this-value; } Public functionSetValue ($value){ return $this->value=$value; } Public functionGetNext () {return $this-Next; } Public functionSetnext ($next){ return $this-Next=$next; }}functionReverse$node){ if(NULL==$node||NULL==$node-GetNext ()) { return $node; } $reversednode= Reverse ($node-GetNext ()); $node->getnext ()->setnext ($node); $node->setnext (NULL); return $reversednode;}functionInsert$node,$value,$position){ $tmp=$node; for($i= 0;$i<$position;$i++){ $tmp=$tmp-GetNext (); } $insertnode=NewNode$value); $insertnode->setnext ($tmp-GetNext ()); $tmp->setnext ($insertnode);}functionDelete$node,$position){ $tmp=$node; for($i= 0;$i<$position;$i++){ $tmp=$tmp-GetNext (); } $tmp->setnext ($tmp->getnext ()GetNext ());}Echo"<pre>";$node=Newnode ();$tmp=$node; for($i= 1;$i<10;$i++){ $nextnode=NewNode$i); $tmp->setnext ($nextnode); $tmp=$nextnode;}Print_r($node);$node=reverse ($node); Insert ($node, 11,3);d elete ($node, 3);Print_r($node);?>
PHP implements the basic operation of the linked list