Visibility of class constant

From: Date: Tue, 03 Feb 2009 05:02:56 +0000
Subject: Visibility of class constant
Groups: php.general 
Request: Send a blank email to php-general+get-287558@lists.php.net to get a copy of this message
I got a weird behaviour of class constant. Suppose I have Index_Controller and Another_Controller classes, both extending Controller class. I define some constants (let's assume I only have one, call it MY_CONST) in Controller class to be used by its descendants. In Index_Controller, I can freely use MY_CONST without parent:: needed. However, this isn't the case with Another_Controller. Without parent:: I got notice Use of undefined constant MY_CONST - assumed 'MY_CONST'. How could this happen and what's the correct behaviour? It's actually nicer to have it without parent::, assuming that constants have protected visibility specifier (which isn't possible AFAIK :-( ). -- View this message in context: http://www.nabble.com/Visibility-of-class-constant-tp21803985p21803985.html Sent from the PHP - General mailing list archive at Nabble.com.

« previous php.general (#287558) next »