Skip to main content
9 events
when toggle format what by license comment
Mar 31, 2014 at 5:36 comment added vivek A better approach would be to use a enum and use color names as a constants there. That way you can manage that as a single source of information about colors and hence keep your code dry.
Mar 28, 2014 at 14:39 comment added cHao @vivekpoddar: If you're going to use constants, they should have less specific names. What happens when i want COLOR_RED to be "blue" instead? :P (And if that will never ever change, why constify it?)
Mar 28, 2014 at 10:29 comment added vivek @MrSmith42: I am not php programmer too ;)
Mar 28, 2014 at 9:54 comment added MrSmith42 @vivekpoddar: I am not a php programmer. You are right defining $red = array("red", "no"); (and also $green) as a constant would be an improvement.
Mar 28, 2014 at 9:50 comment added Szymon Toda This could be even more elegant with array_fill: php.net/manual/en/function.array-fill.php
S Mar 28, 2014 at 9:49 history suggested Szymon Toda CC BY-SA 3.0
syntax error
Mar 28, 2014 at 9:49 review Suggested edits
S Mar 28, 2014 at 9:49
Mar 28, 2014 at 9:28 comment added vivek The above code can be further re factored by avoiding magic numbers i.e. you can use a constant like: define("COLOR_RED", "red") and then use this constant identifier in you code.
Mar 28, 2014 at 7:56 history answered MrSmith42 CC BY-SA 3.0