php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50834 complex string parsing does not parse static classes
Submitted: 2010-01-25 15:34 UTC Modified: 2010-12-14 16:36 UTC
Votes:2
Avg. Score:3.5 ± 1.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: kopelke at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.1 OS: Ubuntu 9.10
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: kopelke at gmail dot com
New email:
PHP Version: OS:

 

 [2010-01-25 15:34 UTC] kopelke at gmail dot com
Description:
------------
The complex string syntax will not include static classes. I cannot use them as output.

Quote from doc: In fact, any value in the namespace can be included in a string with this syntax. Simply write the expression the same way as it would appear outside the string, and then wrap it in { and }. 

I do expect this to be wrong. The documentation states "any value" and A::$a is a valid value for a string.


Reproduce code:
---------------
class A {
  static public $a = 'A';
}

echo "{A::$a}";

Expected result:
----------------
A

Actual result:
--------------
{A::}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-14 16:36 UTC] jani@php.net
-Status: Open +Status: Bogus -Package: Feature/Change Request +Package: *General Issues
 [2010-12-14 16:36 UTC] jani@php.net
Also from the same manual page:

Note:

Functions, method calls, static class variables, and class constants inside {$} work since PHP 5. However, the value accessed will be interpreted as the name of a variable in the scope in which the string is defined. Using single curly braces ({}) will not work for accessing the return values of functions or methods or the values of class constants or static class variables.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Dec 13 11:00:01 2025 UTC