php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68579 Unable to define fraction const in classes
Submitted: 2014-12-09 19:13 UTC Modified: 2014-12-09 19:18 UTC
From: randomdev4+phpbugs at gmail dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5.5.19 OS: Ubuntu 14.04LTS
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: randomdev4+phpbugs at gmail dot com
New email:
PHP Version: OS:

 

 [2014-12-09 19:13 UTC] randomdev4+phpbugs at gmail dot com
Description:
------------
As per test script, define() works, and a simple variable works.  But the moment you try to define a const in a class, PHP complains with the error below:

Parse error: parse error, expecting `','' or `';'' in /Users/ben/test.php on line 8

Test script:
---------------
<?php
define(X,1/8);
echo X."\n";
$y=1/8;
echo $y."\n";
class foo {
    const bar = 1/8;
}
?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-09 19:17 UTC] aharvey@php.net
-Status: Open +Status: Wont fix
 [2014-12-09 19:17 UTC] aharvey@php.net
Support for constant scalar expressions was added in PHP 5.6: http://php.net/manual/en/migration56.new-features.php#migration56.new-features.const-scalar-exprs

Closing won't fix, since we won't be adding this to 5.5.
 [2014-12-09 19:17 UTC] requinix@php.net
-Status: Wont fix +Status: Open
 [2014-12-09 19:17 UTC] requinix@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php

Available in 5.6+.
http://3v4l.org/KCsVh
 [2014-12-09 19:18 UTC] requinix@php.net
-Status: Open +Status: Wont fix
 [2014-12-09 19:18 UTC] requinix@php.net
Ah, sorry aharvey.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 17:01:35 2025 UTC