php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43318 const allowed outside class definition
Submitted: 2007-11-17 13:19 UTC Modified: 2007-11-22 10:47 UTC
From: felipensp at gmail dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3CVS-2007-11-17 (snap) OS:
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: felipensp at gmail dot com
New email:
PHP Version: OS:

 

 [2007-11-17 13:19 UTC] felipensp at gmail dot com
Description:
------------
Const now accepts array?

Reproduce code:
---------------
<?php

const foo = array(1, 2, 3);
var_dump(foo);
var_dump(constant('foo'));

Expected result:
----------------
Error ?

Actual result:
--------------
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-18 03:35 UTC] crrodriguez+php at suse dot de
in 5_3 there seems to be an issue ( maybe a change) that allows "const" outside classes, const outside class seems to be wrong though.

in 5_2 it causes a "syntax error, unexpected T_CONST in.."
 [2007-11-18 23:33 UTC] jani@php.net
Dmitry, I think this is caused by the namespace patches.
 [2007-11-22 10:47 UTC] dmitry@php.net
The bug has been fixed in CVS.

The "const" statement is still allowed outside of namespaces but arrays are disabled.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 10 19:01:34 2025 UTC