note 117145 added to function.constant

From: Date: Tue, 21 Apr 2015 14:02:42 +0000
Subject: note 117145 added to function.constant
Groups: php.notes 
Request: Send a blank email to php-notes+get-202314@lists.php.net to get a copy of this message
If you are referencing class constant (either using namespaces or not, because one day you may want to start using them), you'll have the least headaches when doing it like this: <?php class Foo { const BAR = 42; } ?> <?php namespace Baz; use \Foo as F; echo constant(F::class.'::BAR'); ?> since F::class will be dereferenced to whatever namespace shortcuts you are using (and those are way easier to refactor for IDE than just plain strings with hardcoded namespaces in string literals) ---- Server IP: 72.52.91.14 Probable Submitter: 193.189.87.96 ---- Manual Page -- http://php.net/manual/en/function.constant.php Edit -- https://master.php.net/note/edit/117145 Del: integrated -- https://master.php.net/note/delete/117145/integrated Del: useless -- https://master.php.net/note/delete/117145/useless Del: bad code -- https://master.php.net/note/delete/117145/bad+code Del: spam -- https://master.php.net/note/delete/117145/spam Del: non-english -- https://master.php.net/note/delete/117145/non-english Del: in docs -- https://master.php.net/note/delete/117145/in+docs Del: other reasons-- https://master.php.net/note/delete/117145 Reject -- https://master.php.net/note/reject/117145 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#202314) next »