php - Mapping groups of constant values -


i have lists strings correspond values. example, in company list have microsoft correspond letters ms.

obviously, transposed table in mysql make list extensible but, curiosity, how express in constant form in php ?

p.s: there class-with-constants approach (see accepted answer here: php , enumerations) act enumeration of use seeing enumerations map integer values ?

how using define

define("ms","microsoft"); echo ms; 

this echo microsoft.

http://php.net/manual/en/function.define.php

also link gave possible solution used strings instead. reason acts enum other languages because define values 0 n, instead of doing use string instead.

class companies {     const ms  = 'microsoft';     const ibm = 'international business machines'; }  echo companies::ms; 

i think work.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -