php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13884 Arrays does not work good in objects
Submitted: 2001-10-31 06:17 UTC Modified: 2001-10-31 13:08 UTC
From: starky at udm dot ru Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.0.6 OS: Win98
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
27 - 2 = ?
Subscribe to this entry?

 
 [2001-10-31 06:17 UTC] starky at udm dot ru
<?
 class test{
  var $items;
  function test1(){
   $this->$items['foo']='test';   
  }
 }
 $test=new test;
 $test->test1();
 echo $test->$items['bar'];
?>
last line will output "test"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-31 13:08 UTC] cnewbill@php.net
RTFM
http://www.php.net/manual/en/language.oop.php

HINT: You should not be using a $

WRONG : $this->$items['foo']='test';
RIGHT : $this->items['foo']='test';

WRONG : echo $test->$items['bar']; (unless you had a global items array with items['bar'] = "items['foo']")
RIGHT : echo $test->items['bar'];

-Chris
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 16:01:29 2024 UTC