|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-07-21 17:28 UTC] arpad@php.net
-Status: Open
+Status: Wont fix
[2013-07-21 17:28 UTC] arpad@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 22:00:01 2025 UTC |
Description: ------------ When referencing a class constant, as of PHP 5.3.0, it's possible to reference the class using a variable, e.g. "$myObj::MY_CONST". It's not possible however to use that syntax with object properties, e.g. "$anotherObj->myObj::MY_CONST". I think that's inconsistent. Test script: --------------- <?php class MyClass { const MY_CONST = 'foo'; } $myObj = new MyClass(); // Works, prints "foo" // echo $myObj::MY_CONST; $anotherObj = new stdObject(); $anotherObj->myObj = $myObj; // Raises a parse error echo $anotherObj->myObj::MY_CONST; Expected result: ---------------- Prints "foo" Actual result: -------------- Raises "Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM), expecting ',' or ';'"