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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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 Apr 19 00:01:29 2024 UTC