November 27, 2009
Eid Mubarak for all my brothers and sisters out there!
Comments (1)
November 17, 2009
Ran into something small that might be helpful for other PHP types. This isn’t rocket science, but I don’t see enough examples with static function calls for these functions.
array_walk lets you call a function that will be iterated over all members of an array. In my template class, I had to append some text to the front and back of a search variable. Instead of using the poorly performing foreach loop, I just ran the array_walk function and passed it a function that did the same thing.
array_walk($search, 'template_variable');
I decided that this was not what I wanted (since template_variable would be defined as a function in the global context), and I preferred putting related functions in the same class. I tried this:
array_walk($search, 'self::template_variable');
Of course, this didn’t work. array_walk is not a member of the Template class and as a result it just threw an error stating that “self::template_variable” didn’t exist.
array_walk($search, 'Template::template_variable');
This works fine.
-edit-
There’s something weird and inconsistent about all of this. template_variable works even while private, which throws everything out of wack.
Comments Off
November 9, 2009
I’m delighted that this rescue mission on my T’s restaurant website contract is nearly done. Months of effort on something that was supposed to only take 2 weeks. At least he promised me that he’d consult with me before making any more impossible schedules.
Comments (2)