php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27044 $this->$Variable[] crashes PHP, no output
Submitted: 2004-01-26 05:38 UTC Modified: 2004-01-29 21:12 UTC
From: siggi at junesystems dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.3.4 OS: RedHat 9, Linux 2.4.20-27.9smp
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:
6 - 2 = ?
Subscribe to this entry?

 
 [2004-01-26 05:38 UTC] siggi at junesystems dot com
Description:
------------
When creating a class that contains a class variable array being filled (in this case in the wrong way) like:

$this->$Variable[] = "whatever";
(!! notice second $ )

PHP produces no output and no error message ($Variable is empty BTW, does not exist). In a script with a couple of hundred of lines of code it is a nightmare trying to locate a typo like this with no help from PHP.

Reproduce code:
---------------
class Test {
  var $Variable = Array();
  function Test(){
    $this->$Variable[] = "Test string";
  }
}

$object = new Test();


Expected result:
----------------
Error message.

Actual result:
--------------
No output (this comes from PHP):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-26 20:03 UTC] sniper@php.net
# php t.php 
PHP Fatal error:  Cannot use [] for reading in /home/jani/t.php on line 6
 [2004-01-27 03:07 UTC] siggi at junesystems dot com
Very stupid mistake. E_COMPILE_ERROR was not defined in the php.ini and so the message was not displayed.
 [2004-01-29 21:12 UTC] magnus@php.net
Still not a bug. Leave as bogus.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Dec 02 16:03:40 2021 UTC