ID: 24391
User updated by: flaimo at gmx dot net
Reported By: flaimo at gmx dot net
-Status: Feedback
+Status: Open
Bug Type: Class/Object related
Operating System: win xp
PHP Version: 5CVS-2003-06-29 (dev)
New Comment:
hm, seems like they delete old post after a day or so...
i'll post it here:
-----------------------------------------
<?php
error_reporting(E_ALL & E_NOTICE);
class Comment {
private $id;
private $name;
private $message;
function __construct($id, $name, $message) {
$this->id = $id;
$this->name = $name;
$this->message = $message;
}
function getID() {
return $this->id;
}
function getName() {
return $this->name;
}
function getMessage() {
return $this->message;
}
} // end Comment
class CommentList {
private $list;
function __construct() {
}
function addComment(Comment $comment) {
$this->list[] = $comment;
}
function getComment($id) {
return $this->list[$id];
}
} // end CommentList
$mycomment = new Comment(1, 'Michael', 'Here is my message');
$cl = new CommentList();
$cl->addComment($mycomment);
echo $cl->getComment(0)->message; // why doesn't this line show an
errormessage?
echo $cl->getComment(0)->getMessage();
?>
Previous Comments:
------------------------------------------------------------------------
[2003-06-29 16:43:08] [EMAIL PROTECTED]
status..
------------------------------------------------------------------------
[2003-06-29 16:42:46] [EMAIL PROTECTED]
There is no code there.. Please provide a script to
reproduce the problem.
------------------------------------------------------------------------
[2003-06-29 15:35:42] flaimo at gmx dot net
Description:
------------
the line "echo $cl->getComment(0)->message;" (see sourcecode) should
show an error that i tried to access a private variable, but instead
the script just stops working. without this line the script works fine.
Reproduce code:
---------------
http://pastebin.com/13998. (the linebreak in the comment is not in the
original script!)
Expected result:
----------------
an error message
Actual result:
--------------
nothing
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24391&edit=1