php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18014 Pointers idea in OOP if PHP not consitent
Submitted: 2002-06-27 06:06 UTC Modified: 2002-06-27 06:18 UTC
From: davidktw at singnet dot com dot sg Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.2.1 OS: Windows 2000 Pro
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: davidktw at singnet dot com dot sg
New email:
PHP Version: OS:

 

 [2002-06-27 06:06 UTC] davidktw at singnet dot com dot sg
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 ?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-27 06:18 UTC] sander@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 05:01:27 2025 UTC