|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-06-27 06:18 UTC] sander@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 08:00:02 2025 UTC |
class Node { var $name; var $next; function Node($name) { $this->name = $name; $this->next = NULL; } function getNext() { return $this->next; } function setNext($next) { $this->next = $next; } } $head = new Node("david"); $curr = $head; $curr->setNext(new Node("peter")); $curr = $curr->getNext(); $curr->setNext(new Node("john")); $curr = $head; while ($curr) { print("<p>".$curr->name."</p>"); $curr = $curr->getNext(); } The problem with the code above is.. only "david" is printed.. why isn't the rest of the Nodes printed ? I have checked the linkage If seems like $curr->next is NULL instead of the next Node in the linkedlist... What have I did wrongly ?