note 79727 added to keyword.paamayim-nekudotayim

From: Date: Mon, 10 Dec 2007 14:06:12 +0000
Subject: note 79727 added to keyword.paamayim-nekudotayim
Groups: php.notes 
Request: Send a blank email to php-notes+get-133152@lists.php.net to get a copy of this message
As already pointed out in a previous comment, there is no way to statically access variables, i wrote this small workaround <?php class A { var $MY_VIRTUAL_CONST = 1; function MY_VIRTUAL_CONST() { $vars = get_class_vars(__CLASS__); return $vars[strToUpper(__FUNCTION__)]; } } echo A::MY_VIRTUAL_CONST(); ?> This magically retrieves the correct value without creating an object instance and its easily copy & pasteable, as the methods content is completly generic. ---- Server IP: 209.41.74.194 Probable Submitter: 15.203.169.124 ---- Manual Page -- http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php Edit -- https://master.php.net/note/edit/79727 Del: integrated -- https://master.php.net/note/delete/79727/integrated Del: useless -- https://master.php.net/note/delete/79727/useless Del: bad code -- https://master.php.net/note/delete/79727/bad+code Del: spam -- https://master.php.net/note/delete/79727/spam Del: non-english -- https://master.php.net/note/delete/79727/non-english Del: in docs -- https://master.php.net/note/delete/79727/in+docs Del: other reasons-- https://master.php.net/note/delete/79727 Reject -- https://master.php.net/note/reject/79727 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#133152) next »