The foreach identifier and closures

Edit: this all changes in C# 5, with a change to where the variable is defined (in the eyes of the compiler). From C# 5 onwards, they are the same. Before C#5 The second is safe; the first isn’t. With foreach, the variable is declared outside the loop – i.e. Foo f; while(iterator.MoveNext()) { f … Read more

Enumerations on PHP

Depending upon use case, I would normally use something simple like the following: abstract class DaysOfWeek { const Sunday = 0; const Monday = 1; // etc. } $today = DaysOfWeek::Sunday; However, other use cases may require more validation of constants and values. Based on the comments below about reflection, and a few other notes, … Read more