|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-10-27 13:43 UTC] jani@php.net
[2008-10-27 14:18 UTC] victor at equillon dot ro
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 14:00:02 2025 UTC |
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