|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-07-09 13:10 UTC] divinity76 at gmail dot com
Description:
------------
the same way "{$this->foo}" and $this->foo and this::CONSTANT is legal, "{$this::CONSTANT}" should also be legal
Test script:
---------------
<?php
class C{
const CON=456;
function f(){
echo "123{$this::CON}";
}
}
(new C())->f();
Expected result:
----------------
123456
Actual result:
--------------
Parse error: syntax error, unexpected token "}", expecting "->" or "?->" or "{" or "[" in /in/PIN5O on line 5
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
The current limitation here is that that it start's with {$ and the contents of {} are a "variable". Class constants aren't considered a variable. This could be relaxed in two ways: * Specifically allow class constants in addition to variables. * Allow any expression (subject to the limitation that it must start with $). This would also make something like "{$a + $b}" valid, but not "{1 + $a}". Both are backwards compatible, in that they only allow things that were previously a syntax error. This is unlike the case where "{any expression}" is allowed, which would be a major break. In any case, such a change would need an RFC.