php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31554 can't assign function output to class constant
Submitted: 2005-01-14 16:16 UTC Modified: 2005-01-14 19:48 UTC
From: pcarmody at c-spanarchives dot org Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.0.3 OS: SunOS 5.8
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: pcarmody at c-spanarchives dot org
New email:
PHP Version: OS:

 

 [2005-01-14 16:16 UTC] pcarmody at c-spanarchives dot org
Description:
------------
Attempting to use a function to generate the value for assignment to a class constant causes a parse error.


Reproduce code:
---------------
<?php
class MyClass {
  const good = "Blah";  // will work
  const bad = substr(0, 3, "Blah");  // results in parse error
}
?>

Actual result:
--------------
Parse error: parse error, unexpected '(', expecting ',' or ';'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-14 19:48 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 14:01:36 2025 UTC