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 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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
44 - 43 = ?
Subscribe to this entry?

 
 [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: Mon Jun 03 20:01:31 2024 UTC