note 84629 added to keyword.paamayim-nekudotayim

From: Date: Tue, 22 Jul 2008 18:12:13 +0000
Subject: note 84629 added to keyword.paamayim-nekudotayim
Groups: php.notes 
Request: Send a blank email to php-notes+get-142513@lists.php.net to get a copy of this message
Using PHP 4, I was unable to see an easy method for retrieving static constants in a library, as well as static functions. There was no need to set variables, as the library is final, used for Configuration settings. class StaticLibrary { //static constants are set here function finalConstants(&$Vars) { $Vars['someVar'] = 'Hello'; $Vars['anotherVar'] = 'World'; $Vars['moreVars'] = 'Keep It Coming'; } //usage: StaticLibrary::vars('someVar') function vars($v) { static $Vars; if (!is_array($Vars)) { $Vars = array(); StaticLibrary::finalConstants($Vars); } //setup access to the static contants in our Final library return($Vars[$v]); //return some var } //usage: StaticLibrary::staticFunction('Some string and I want to ') function staticFunction($str) { $str .= 'freak that string!'; return $str; } } I appreciate the ideas below!! ---- Server IP: 64.71.164.2 Probable Submitter: 98.203.244.19 ---- Manual Page -- http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php Edit -- https://master.php.net/note/edit/84629 Del: integrated -- https://master.php.net/note/delete/84629/integrated Del: useless -- https://master.php.net/note/delete/84629/useless Del: bad code -- https://master.php.net/note/delete/84629/bad+code Del: spam -- https://master.php.net/note/delete/84629/spam Del: non-english -- https://master.php.net/note/delete/84629/non-english Del: in docs -- https://master.php.net/note/delete/84629/in+docs Del: other reasons-- https://master.php.net/note/delete/84629 Reject -- https://master.php.net/note/reject/84629 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#142513) next »