php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #16079 Allow '.' (concat) operator on static strings
Submitted: 2002-03-14 14:01 UTC Modified: 2014-10-12 14:18 UTC
Votes:14
Avg. Score:4.4 ± 1.0
Reproduced:12 of 12 (100.0%)
Same Version:7 (58.3%)
Same OS:9 (75.0%)
From: steve dot venable at lmco dot com Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: * 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 !
Your email address:
MUST BE VALID
Solve the problem:
40 + 33 = ?
Subscribe to this entry?

 
 [2002-03-14 14:01 UTC] steve dot venable at lmco dot com
I can understand requiring constants for static initialization.  But can the parser be modified to support operators on constants for static initializations?  This is especially true for long strings which I can't even break at the end of line for readability.  (I almost submitted this as a bug :)

Examples:
            $v = 1 + 2;   // Okay
     static $s = 1 + 2;   // Fails parse

            $v = "this long "
                 ."string";  // Okay
     static $s = "this long "
                 ."string";  // Fails parse

Since only constants are involved the parser could collapse the expression without difficulty.  This makes the code much more readable (again thinking of very long strings).  In my case I'm building an array of error messages and don't want the array build to occur everytime the function is called, hence I made it static.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-02 02:41 UTC] jani@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem -Operating System: All +Operating System: * -PHP Version: 4.1.1 +PHP Version: *
 [2014-10-12 14:18 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2014-10-12 14:18 UTC] nikic@php.net
Supported in 5.6
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 18:02:40 2024 UTC