ID: 46401
Updated by: [EMAIL PROTECTED]
Reported By: victor at equillon dot ro
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Linux
PHP Version: 5.2.6
New Comment:
I suggest you turn on full error_reporting on your development
machine:
# php -derror_reporting=E_ALL -n t.php
Notice: Trying to get property of non-object in /home/jani/t.php on
line 18
And then read about constructors and classnames..
Previous Comments:
------------------------------------------------------------------------
[2008-10-27 13:17:20] victor at equillon dot ro
Description:
------------
When concatenating a string with an attribute of a class, the attribute
is considered to be void or something. It doesn't always run like that.
It can be fixed by doing this:
echo "Monster ".($this->monsters[0]->name)." hit something";
Reproduce code:
---------------
class Monster {
public $name;
}
class test {
private $monsters;
public function init() {
for ($i=0; $i<100; $i++) {
$this->monsters[$i] = new Monster();
$this->monsters[$i]->name = "test";
}
}
public function test() {
echo "Monster ".$this->monsters[0]->name." hit something";
}
}
$abc = new test();
$abc->init();
$abc->test();
Expected result:
----------------
Monster test hit something
Actual result:
--------------
Monster hit something
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46401&edit=1