Bug #64774 [Opn->Nab]: reassign of class's constant

From: Date: Fri, 03 May 2013 16:41:48 +0000
Subject: Bug #64774 [Opn->Nab]: reassign of class's constant
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-178784@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64774&edit=1

 ID:                 64774
 Updated by:         nikic@php.net
 Reported by:        ghanbari dot daniel at gmail dot com
 Summary:            reassign of class's constant
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 Operating System:   ubuntu12.1
 PHP Version:        5.3.24
 Block user comment: N
 Private report:     N

 New Comment:

$this->NAME is a property. You are looking for self::NAME or test::NAME.


Previous Comments:
------------------------------------------------------------------------
[2013-05-03 16:29:23] ghanbari dot daniel at gmail dot com

Description:
------------
---
From manual page: http://www.php.net/language.oop5.constants
---

why anyone can override constant of class?
in c++, i can assign const value only in construct method of class

Test script:
---------------
<?php

class test{
	const NAME = 100;
	public function ech(){
		$this->NAME = 300;
		$this->echt();
	}
	public function echt(){
		$this->NAME = 200;
		echo $this->NAME;
	}
}

$a=new test();
echo $a->ech();



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64774&edit=1


Thread (2 messages)

« previous php.bugs (#178784) next »