php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26601 Property name must be a string
Submitted: 2003-12-12 07:29 UTC Modified: 2003-12-14 21:13 UTC
From: tomas dot matousek at matfyz dot cz Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 4.3.4 OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tomas dot matousek at matfyz dot cz
New email:
PHP Version: OS:

 

 [2003-12-12 07:29 UTC] tomas dot matousek at matfyz dot cz
Description:
------------
The rules for property names are inconsistent.
See comments in submitted code.


Reproduce code:
---------------
<?
  // this is ok  
  $a->{"x"} = 1;

  // fatal error:
  $a->{18.5} = 1;

  // fatal error:
  $a->{1} = 1;

  // but this one passes thru:
  $a->{true} = 1;

  // so do this:
  $a->{18.5} = 1;

  // and this too:
  $a->{1} = 1;
?>

Expected result:
----------------
Either convert floats, integers and booleans to strings automatically or report fatal error in all cases when property name is not a string (i.e. if it is object, array, resource, boolean, integer, float, NULL).


Actual result:
--------------
Fatal error: Property name must be a string ...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-12 07:34 UTC] tomas dot matousek at matfyz dot cz
Sorry for a mistake in code. There should be:

  // so do this:
  $a->{18.5*1} = 1;

  // and this too:
  $a->{1*1} = 1;
 [2003-12-14 21:13 UTC] sniper@php.net
Fixed in PHP 5, won't fix in PHP 4.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 03:01:27 2024 UTC