php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62342 self:$var - PHP should produce an error
Submitted: 2012-06-17 14:42 UTC Modified: 2012-06-17 20:45 UTC
From: 007not at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.4Git-2012-06-17 (snap) OS: win, linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: 007not at gmail dot com
New email:
PHP Version: OS:

 

 [2012-06-17 14:42 UTC] 007not at gmail dot com
Description:
------------
Take a good look in the code, a special attention to : at line 10. I think that PHP should produce an error in this line.

Test script:
---------------
<?php
class test
{
	static $var = 0;

	static function run()
	{
		$var = 1;
		$newvar = 2;
		self:$var = $newvar; //where is error?! this is line 10

		echo $var . PHP_EOL;
		echo self::$var . PHP_EOL;
		//echo self:$var; //rise error!
	}
}
test::run();

Expected result:
----------------
an error in line 10

Actual result:
--------------
2
0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-17 20:45 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2012-06-17 20:45 UTC] nikic@php.net
`self:` creates a goto label with name "self". You could write that line as

    self:
    $var = $newvar;

So the code is perfectly valid.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 23:01:32 2025 UTC