Func_get_args()
-
You'd probably imagine that someone with limited PHP skills is likely to know about how simple function parameters work and be unaware of something a little more advanced like func_get_args().
But what about the opposite? I'm guessing that was the case with the author of a class I found where every single function had been implemented with this technique:
/** * * Creates a counter on HowerBox 1 1 10 "mm:ss" * * @param Integer $params[0] X coordinate * @param Integer $params[1] Y coordinate * @param Integer $params[2] Start time * @param String $params[3] Format "mm:ss" */ function addTimeCounter(){ $this->select(); $params = func_get_args(); $paramStr = $params[0] . ' ' . $params[1] . ' ' . $params[2] . ' "' . $params[3] . '"'; $this->Agent->fs('hbtimecounter ' . $paramStr); }
For bonus points: the class was a wrapper around a feature called hover box, but the class itself was named HowerBox. Furthermore, many of the comments inside the class actually spelled it with a 'v' while others used the 'w'.
-
Of course he would use func_get_args(), because you never know when you want to change the number of parameters!
-
At least each argument is documented...
-
What does $this->Agent->fs() do? I have a strange feeling it involves split()...
-
@Dinnerbone said:
What does $this->Agent->fs() do? I have a strange feeling it involves split()...
We use PHP with a custom extension as a scripting language on top of another app. The communication between the two is done via this call.
-
probably an ex-perl programmer.