php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73494 Class name As Const
Submitted: 2016-11-11 08:36 UTC Modified: 2016-11-11 08:41 UTC
From: takeo dot tanha at livce dot com Assigned:
Status: Duplicate Package: Class/Object related
PHP Version: 7.0.13 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:
38 - 9 = ?
Subscribe to this entry?

 
 [2016-11-11 08:36 UTC] takeo dot tanha at livce dot com
Description:
------------
in example we have a class (bar) that have a static function that do somthing.
when in other class (foo) we Define bar class name as Const and when we want use it to run static  function we have an error : 

Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) in index.php on line 7

Test script:
---------------
class foo
{
	const MY_CONST = "bar";
	public function __construct()
	{
		self::MY_CONST::message();
	}
}
class bar
{
	public static function message()
	{
		echo "hello";
	}
}
new foo();

Expected result:
----------------
Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) in index.php on line 7


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-11 08:40 UTC] takeo dot tanha at livce dot com
-Status: Open +Status: Closed
 [2016-11-11 08:40 UTC] takeo dot tanha at livce dot com
go to this : https://bugs.php.net/bug.php?id=73495
 [2016-11-11 08:41 UTC] requinix@php.net
-Status: Closed +Status: Duplicate
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Jan 28 00:03:34 2022 UTC