php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38711 Expression with class constants erreor
Submitted: 2006-09-04 11:25 UTC Modified: 2006-09-04 11:32 UTC
From: jd at trickytools dot com Assigned:
Status: Not a bug Package: Compile Failure
PHP Version: 5.1.6 OS: Linux RedHat 4
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: jd at trickytools dot com
New email:
PHP Version: OS:

 

 [2006-09-04 11:25 UTC] jd at trickytools dot com
Description:
------------
It seems that initializing static class member with constant expression generates a syntax error

Reproduce code:
---------------
<?php
class C {
static public $m = 1 + 2;  // syntax error !
};
?>


Expected result:
----------------
There should not be any compilation error

Actual result:
--------------
PHP Parse error:  syntax error, unexpected '(' in /var/www/html/test.php on line 3


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-04 11:32 UTC] tony2001@php.net
Expressions cannot be executed in compile time, when class constants/members are declared.
This is expected behaviour.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 22 12:00:02 2025 UTC