array_unique function is a native function that will extract distinct values in an array. array_count_values is also a native function that will extract distinct values in an array, and count the number of occurrences. array_count_values actually does a lot more work than array_unique by providing a count of the distinct values, on top of finding […]
I’ll be giving a talk ‘automated PHP code audits‘ to the 010php user group, in Rotterdam. “Even nowadays, PHP code is mostly manually audited. Expert pore over actual code, in search for bugs or code smells. Actually, it is possible to have PHP do this work itself ! Strengthened with the internal Tokenizer, bolstered by […]
Switch statements in PHP link a situation (the cases) to code to be executed. Just like this : switch ($a) { case ‘a’ : /* code here */ case ‘b’ : /* code here */ default : /* code here */ } Duplicate code in switch statements With the size of the switch, it is easy to miss that cases […]
Reviewing code is like checking your own copy before handing in an exam : last exam I took was driving test (incredible, I know), and I passed by 0 the 100 questions quiz. I do remember changing three or four answers while reviewing the answers, and even as I don’t know for sure about it, I […]