Bug #64774 [Opn->Nab]: reassign of class's constant
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)