|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-03-30 08:39 UTC] pedja at uzice dot net
[2004-03-30 08:42 UTC] iliaa@php.net
[2004-03-30 08:44 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 16:00:01 2025 UTC |
Description: ------------ I created array as class property. It does not work as expected. Here is an example: <?php class testclass { var $testarray = array(); function testclass() { for ($counter = 65; $counter < 75; $counter++) { $this->$testarray[$counter] = chr ($counter); } } } $testvar = new testclass(); print_r ($testvar->$testarray); ?> The result of this code is array containing one record. It should contain several records. If I cahnge this code to use global variable instead of class property ... <?php class testclass { function testclass() { global $testarray; for ($counter = 65; $counter < 75; $counter++) { $testarray[$counter] = chr ($counter); } } } $testvar = new testclass(); print_r ($testarray); ?> ... it works: I get what I expected - array containing several records.