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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: starky at udm dot ru
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sat Dec 21 16:01:28 2024 UTC